-
Notifications
You must be signed in to change notification settings - Fork 739
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
🐛 BUG: Usage of "typeof module" causes error "The uploaded script has no registered event handlers. [code: 10068]" #1668
Comments
I got the same issue after integrated It seems due to // node_modules/symbol-observable/es/index.js
var root;
typeof self < "u" ? root = self : typeof window < "u" ? root = window : typeof globalThis < "u" ? root = globalThis : typeof module < "u" ? root = module : root = Function("return this")();
var result = symbolObservablePonyfill(root); I can use // Deploy successfully
// node_modules/symbol-observable/es/index.js
var root;
typeof self < "u" ? root = self : typeof window < "u" ? root = window : typeof globalThis < "u" ? root = globalThis : false ? root = module : root = Function("return this")();
var result = symbolObservablePonyfill(root); |
This is due to the way we handle the two types of worker formats. From /**
* A function to "guess" the type of worker.
* We do this by running a lightweight build of the actual script,
* and looking at the metafile generated by esbuild. If it has a default
* export (or really, any exports), that means it's a "modules" worker.
* Else, it's a "service-worker" worker. This seems hacky, but works remarkably
* well in practice.
*/ For now you can bypass this "guessing" by using the command line flag Will discuss with the team about a potentially "better" way of detecting the type of worker to handle situations like this. |
Is there any update on this issue? Encountering it using |
I'm also experiencing this issue, and it seems to be a bug in Wrangler itself. By inspecting the outputs of export default require_build(); Thus, wrangler detects that I have a I believe this is happening, because esbuild is being run with var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb2, mod) => function __require() {
return mod || (0, cb2[__getOwnPropNames(cb2)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var require_build = __commonJS({
"build/index.js"(exports, module) {
// ... my bundled code here ...
}
});
export default require_build(); |
I'm also seeing this failure, but only in We're using the It's a bit hard to debug where the issue's coming from but I do see a
We first ran into this a few months ago while upgrading from remix Since remix can only run the diff --git a/node_modules/wrangler/wrangler-dist/cli.js b/node_modules/wrangler/wrangler-dist/cli.js
index c999f82..fd9d75d 100644
--- a/node_modules/wrangler/wrangler-dist/cli.js
+++ b/node_modules/wrangler/wrangler-dist/cli.js
@@ -141752,7 +141752,7 @@ async function guessWorkerFormat(entryFile, entryWorkingDirectory, hint, tsconfi
absWorkingDir: entryWorkingDirectory,
metafile: true,
bundle: false,
- format: "esm",
+ /* format: "esm", // see https://github.com/cloudflare/wrangler2/issues/1668 https://github.com/cloudflare/wrangler2/pull/2396#issuecomment-1346940067 https://github.com/cloudflare/wrangler2/pull/2396#issuecomment-1347312494 */
target: "es2020",
write: false,
loader: { original patchbefore we saw https://github.com//pull/2396#issuecomment-1346940067diff --git a/node_modules/wrangler/wrangler-dist/cli.js b/node_modules/wrangler/wrangler-dist/cli.js
index c999f82..a596b06 100644
--- a/node_modules/wrangler/wrangler-dist/cli.js
+++ b/node_modules/wrangler/wrangler-dist/cli.js
@@ -141778,7 +141778,7 @@ async function guessWorkerFormat(entryFile, entryWorkingDirectory, hint, tsconfi
const scriptExports = entryPoints[0][1].exports;
if (scriptExports.length > 0) {
if (scriptExports.includes("default")) {
- guessedWorkerFormat = "modules";
+ guessedWorkerFormat = "service-worker"; console.log("patch to force 'service-worker' format"); /* Remix can *only* ship service-workers on Cloudflare https://github.com/cloudflare/wrangler2/issues/1668 & https://github.com/remix-run/remix/issues/764 */
} else {
logger.warn(
`The entrypoint ${import_node_path10.default.relative( failing-remix-development.js.zip |
Wrangler automatically detects whether your code is a `modules` or `service-worker` format Worker based on the presence of a `default` `export`. This check currently works by building your entrypoint with `esbuild` and looking at the output metafile. Previously, we were passing `format: "esm"` to `esbuild` when performing this check, which enables *format conversion*. This may introduce `export default` into the built code, even if it wasn't there to start with, resulting in incorrect format detections. This change removes `format: "esm"` which disables format conversion when bundling is disabled: https://esbuild.github.io/api/#format. We may want to use a package like `es-module-lexer` in the future, but this issue is affecting users, and this is probably the simplest fix. Closes #1668 Closes #2396 Ref #2737
Wrangler automatically detects whether your code is a `modules` or `service-worker` format Worker based on the presence of a `default` `export`. This check currently works by building your entrypoint with `esbuild` and looking at the output metafile. Previously, we were passing `format: "esm"` to `esbuild` when performing this check, which enables *format conversion*. This may introduce `export default` into the built code, even if it wasn't there to start with, resulting in incorrect format detections. This change removes `format: "esm"` which disables format conversion when bundling is disabled: https://esbuild.github.io/api/#format. We may want to use a package like `es-module-lexer` in the future, but this issue is affecting users, and this is probably the simplest fix. Closes #1668 Closes #2396 Ref #2737
* Disable format conversion when detecting format, closes #1668 Wrangler automatically detects whether your code is a `modules` or `service-worker` format Worker based on the presence of a `default` `export`. This check currently works by building your entrypoint with `esbuild` and looking at the output metafile. Previously, we were passing `format: "esm"` to `esbuild` when performing this check, which enables *format conversion*. This may introduce `export default` into the built code, even if it wasn't there to start with, resulting in incorrect format detections. This change removes `format: "esm"` which disables format conversion when bundling is disabled: https://esbuild.github.io/api/#format. We may want to use a package like `es-module-lexer` in the future, but this issue is affecting users, and this is probably the simplest fix. Closes #1668 Closes #2396 Ref #2737 * fixup! Disable format conversion when detecting format, closes #1668
Following up to say we updated to |
What version of
Wrangler
are you using?2.0.25
What operating system are you using?
Mac
Describe the Bug
Attempting to deploy the following code causes the error:
"The uploaded script has no registered event handlers. [code: 10068]"
Commenting out the last line causes the deployment to function as expected:
EDIT: Seems the same thing is happening if I change the variable after
typeof
toexports
. Is this thing specifically trying to prevent me from detecting Node.js vs Cloudflare?The text was updated successfully, but these errors were encountered: