-
Notifications
You must be signed in to change notification settings - Fork 233
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
fix(worker-build): prevent script will never generate a response #256
base: main
Are you sure you want to change the base?
Conversation
export * from "./index_bg.js"; | ||
export default { | ||
fetch: async (...args) => { | ||
INSERT_INIT(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is replaced in the script below
@@ -130,14 +131,50 @@ fn bundle(esbuild_path: &Path) -> Result<()> { | |||
"--outfile=shim.mjs", | |||
]); | |||
|
|||
if !no_minify { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't run minify, as we need the non-minified source to run transforms
fs::write(path.join("./shim.mjs"), result)?; | ||
|
||
// re-bundle the shim with minification flag | ||
if !no_minify { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we re-run esbuild to minify it
ping @zebp i wonder if you know who to hit up to get this in, this is blocking me from using worker-rs |
left a reply in the issue |
Is there any update on this? |
|
||
return imports.fetch(...args); | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is missing the scheduled
entrypoint
@@ -1,7 +1,12 @@ | |||
import * as imports from "./index_bg.js"; | |||
export * from "./index_bg.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents Durable Objects from being exported no?
This fixes #255
There's no clean way to convert the
index_bg.js
which contains ESM exports, into a function which is called on eachfetch()
.So in this PR, I basically split the two parts of the bundle up and move the initialization inside the fetch function, by replacing the
INSERT_INIT()
tokenThis is kinda hacky, but it works. It fixes the script will never generate a response errors that can occur when sharing the wasm state across requests.