next.js
1c09ec59 - [ts-next-plugin] clean up unused proxy (#78539)

Commit
276 days ago
[ts-next-plugin] clean up unused proxy (#78539) Cleaned up a leftover unused proxy following up on https://github.com/vercel/next.js/pull/78237. Besides being unused, there was an issue reported from a large repository. The repository was a monorepo, and the apps' modules were shared with each other. The user received an error: ``` [trace] <semantic> Response received: definitionAndBoundSpan (951). Request took 0 ms. Success: false . Message: Error processing request. Cannot read properties of undefined (reading 'updateFromProject') TypeError: Cannot read properties of undefined (reading 'updateFromProject') at synchronizeHostData (...) at Object.getProgram (...) at getSource (...) at getEntryInfo (...) at proxy.getDefinitionAndBoundSpan ``` The issue begins when `getDefinitionAndBoundSpan` is triggered—typically via `Cmd + Click` or even hovering(!) to view definitions, imports, or module references. In our case, since the repository contains multiple apps, each enabling the plugin, navigating across apps using `Cmd + Click` caused `getDefinitionAndBoundSpan` to fire across multiple plugin instances. The root cause is that when `getDefinitionAndBoundSpan` is triggered, it calls `synchronizeHostData()` and checks whether it is to update the project by checking the `host.updateFromProject` exists. However, the Language Service Host is somehow `undefined` (assuming memory is overloaded due to initiating multiple plugins), so we received the error above. x-ref: https://github.com/microsoft/TypeScript/blob/11e79327598db412a161616849041487673fadab/src/services/services.ts#L1692-L1693 If we clean up this `getDefinitionAndBoundSpan` proxy, the error above will be gone, but `synchronizeHostData` is called pretty much every time on language service requests, including `getSemanticDiagnostics` we are still proxying — a potential issue we can't control that could happen for complicated repositories like the above. x-ref: [slack thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1744231020199229)
Author
Parents
Loading