Constructing a WorkerEntrypoint from userland#3782
Merged
Conversation
Member
|
I guess this is just because the constructor is declared to take workerd/src/workerd/api/worker-rpc.h Lines 493 to 500 in 1dfb447 I think literally just changing the type of |
Member
|
Can we convert the stample into a test, please? Our samples are meant to be documentation. We should only have samples covering common use cases, to avoid overwhelming users with noise. |
Member
|
Could add this to js-rpc-test pretty easily. |
355f22c to
124d73a
Compare
124d73a to
04f97bd
Compare
Collaborator
|
@kentonv added test and cleaned up sample |
kentonv
approved these changes
Mar 24, 2025
penalosa
added a commit
to cloudflare/workers-sdk
that referenced
this pull request
Mar 27, 2026
…ypoint with mocked env Closes #7077. The underlying fix landed in workerd via cloudflare/workerd#3782, which relaxed the WorkerEntrypoint constructor to accept any object as ctx rather than requiring a native ExecutionContext.
5 tasks
penalosa
added a commit
to cloudflare/workers-sdk
that referenced
this pull request
Mar 27, 2026
…ypoint with mocked env Closes #7077. The underlying fix landed in workerd via cloudflare/workerd#3782, which relaxed the WorkerEntrypoint constructor to accept any object as ctx rather than requiring a native ExecutionContext.
penalosa
added a commit
to cloudflare/workers-sdk
that referenced
this pull request
Mar 31, 2026
…ypoint with mocked env Closes #7077. The underlying fix landed in workerd via cloudflare/workerd#3782, which relaxed the WorkerEntrypoint constructor to accept any object as ctx rather than requiring a native ExecutionContext.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a sample that demonstrates that it's not possible to construct a
WorkerEntrypointin userland with a user-providedctxobject. Instead, this error appears:This is important for the Vitest integration because we need to be able to (within a single "real" execution context):
waitUntils in the custom execution context to be settledThis works with default export-style workers, because the
fetch()method can just be called directly with the custom execution context, but that's not possible withWorkerEntrypoint-style workers.Or at least that was the case! Thanks to the changes now in this PR, the above is possible—and
WorkerEntrypointcan be constructed with any object, allowing for custom execution contexts.