Skip to content
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

Optionally run Response Promise to completion in waitUntil context #653

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

kflansburg
Copy link
Contributor

When a client disconnects, code is not run to clean up wasm-bindgen's "heap", and thus objects associated with the request leak. wasm-bindgen suggests the use of FinalizationRegistry, which we do not currently support due to security reasons.

This change allows user's to specify RUN_TO_COMPLETION environment variable when running worker-build, which tricks the Workers runtime into executing the Promise that resolves the Response in a waitUntil context, even if the client disconnects. This should be used with caution, as your code may have side effects that you would not want to run if the client disconnects.

Below is a graph of Wasm heap usage over time during a load test, first with existing behavior, and second with RUN_TO_COMPLETION enabled.

output

@zebp zebp merged commit a68cff1 into main Nov 19, 2024
5 checks passed
@zebp zebp deleted the kflansburg/run-to-completion branch November 19, 2024 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants