-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Find approach that doesn't write to disk in Next.js SDK proxyLoader
#5944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@eggplants Could you provide your Node/Webpack versions as well here? I wonder why Currently there is no other workaround for this other than disabling Perhaps we need to investigate using a virtual plugin, or using the |
$ node --version
v16.13.0
Yes. Here is a part of my version: '3.6'
services:
...
nextjs:
build:
context: ./
dockerfile: ./Dockerfile
image: foo-bar-nextjs
volumes:
- ./src:/app/src:ro
... |
To set |
|
So I have to either give up on making volume read-only or using |
Yes for now, but we can look at improving this. PRs are also welcome if you have any ideas. |
If we can get the rollup to do it without temporary files, this issue might solve the problem. sentry-javascript/packages/nextjs/src/config/loaders/proxyLoader.ts Lines 53 to 71 in 7e03836
|
proxyLoader
proxyLoader
…6021) In the proxy loader used by the nextjs SDK to autowrap user code, we currently write a temporary file to disk for each proxy module we create, because by default Rollup's API expects a path to a file, not the file's contents. It's a little bit of an ugly hack, though, and can cause problems because it writes to the user's source directory rather than to their build directory. This switches to the use of virtual files, using the `@rollup/virtual-plugin` plugin. For unclear reasons, this seems to change (and not in a good way) the base of the relative paths calculated by Rollup when transforming the proxy templates' `import * as wrappedFile from <wrapped file>` and `export * from <wrapped file>` statements. We already have to manually fix those statements, to undo the fact that Rollup substitutes underscores for any square brackets which appear in the paths, but that fix is straightforward because it's very easy to predict what the wrong version will look like, so finding it and overwriting it with the right version is easy. With the relative path base change introduced by the virtual plugin it's not as simple, though, because there's not an easily-discernible pattern to what new base gets picked. (Sometimes it's `pages/`, sometimes it's `pages/api`, sometimes the path uses `./xxx`, sometimes the path uses `../xxx`...) Therefore, rather than trying to nail down and then handle each case of that logic in order to _predict_ what the incorrect path will be, this looks for the transformed version of the whole `import * as wrappedFile from <wrapped file>` statement and reads the incorrect path from there using a regex. Note: This is a second attempt at #5960, which was reverted. H/t to the author of that PR, @lforst, for rubber-ducking this new solution. Fixes #5944.
Discussed in #5943
Originally posted by eggplants October 13, 2022
proxyLoader
createssrc/pages/temp***.js
. It causes the following error in my nextjs project on Docker:Current only workaround is to set
autoInstrumentServerFunctions: false
. Is there any other way?(
@sentry/nextjs
: 7.15.0,next
: 12.3.1)The text was updated successfully, but these errors were encountered: