remix: Not able to deploy on Fly via Docker: `top-level await` error
What version of Remix are you using?
v1.14.0
Are all your remix dependencies & dev-dependencies using the same version?
- Yes
Steps to Reproduce
Deploy to Fly using Docker
Expected Behavior
Build should succeed
Actual Behavior
Build step is failing:
#17 [build 6/6] RUN npm run build
#17 14.11 ✘ [ERROR] This require call is not allowed because the imported file "node_modules/@jspm/core/nodelibs/browser/worker_threads.js" contains a top-level await
#17 14.11
#17 14.11 node_modules/@prisma/client/runtime/index.js:13:8230:
#17 14.11 13 │ ...ssageOnPort:LR}=require("worker_threads"),xR=["GET","HEAD","POS...
#17 14.11 ╵ ~~~~~~~~~~~~~~~~
#17 14.11
#17 14.11 The top-level await in "node_modules/@jspm/core/nodelibs/browser/worker_threads.js" is here:
#17 14.11
#17 14.11 node_modules/@jspm/core/nodelibs/browser/worker_threads.js:97:49:
#17 14.11 97 │ ...rkerData, environmentData }] = await once(parentPort, 'message'));
#17 14.11 ╵ ~~~~~
#17 14.11
#17 14.11
#17 14.11 ✘ [ERROR] This require call is not allowed because the imported file "node_modules/@jspm/core/nodelibs/browser/worker_threads.js" contains a top-level await
#17 14.11
#17 14.11 node_modules/@prisma/client/runtime/index.js:56:58637:
#17 14.11 56 │ ...MessagePort:SU}=require("worker_threads"),uA,WA=class extends E...
#17 14.11 ╵ ~~~~~~~~~~~~~~~~
#17 14.11
#17 14.11 The top-level await in "node_modules/@jspm/core/nodelibs/browser/worker_threads.js" is here:
#17 14.11
#17 14.11 node_modules/@jspm/core/nodelibs/browser/worker_threads.js:97:49:
#17 14.11 97 │ ...rkerData, environmentData }] = await once(parentPort, 'message'));
#17 14.11 ╵ ~~~~~
#17 14.11
#17 14.11
#17 14.15 ERROR: "build:remix" exited with 1.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 3
- Comments: 17 (1 by maintainers)
It seems like Remix is suddenly importing files that used to be tree-shaken out of the browser build. In my other project, Sentry was also getting included despite never being used client-side. This may be specific to this kind of import:
import * as Sentry from "@sentry/node";I think Remix needs a few things to put these issues to rest:
tree-like output, that shows the module import graph)"fs"or other known server runtime prefixes, like"node:*"serverOnlyImports: [ "@org/package", "**/server-code/**" ]I had the same problem and solved it by migrating some deprecated
@prisma/client/runtimeimports in my app to@prisma/client/runtime/library.If you get this during startup:
It might also work for you.
I was able to circumvent the issue with an npm override:
Ok, thank you for all the help… I deleted everything in my routes until it was just and index, root, and entry.x files For me it seems it is an my
session.server.tswhich i moved into a “package” in my monorepo then imported poorly.I basically couldn’t narrow it down to just one thing… but basically if my mono-repo packages bleed any node dep than it borked. Basically treeshaking was working or i missed something.
for me i re-exported all my monorepo packages in a file like
utils/[package].serveri wish i could just mark packages as server only.
Looks like another issue popped up and it might be related to the overrides that I tried:
This error persists even with no routes, so it appears to be including node polyfills in the browser build. I’m not sure if this is actually related to the override or not since I can’t build without that override.