Repository navigation
fix(bundle): Deno.bundle work in Worker - #31316
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where Deno.bundle would throw an exception when called from within a Worker context. The fix involves passing the bundle provider to workers so they can perform bundling operations.
Key Changes
- Added
bundle_providerfield toWebWorkerServiceOptionsto enable bundle functionality in workers - Modified worker initialization to pass the cloned bundle provider from the main worker factory
- Added comprehensive test coverage for bundling within a worker context
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| runtime/web_worker.rs | Added bundle_provider field to WebWorkerServiceOptions struct and passed it to the bundle runtime initialization |
| cli/lib/worker.rs | Populated the bundle_provider field when creating web worker services from the shared state |
| tests/specs/bundle/worker/test.jsonc | Added test configuration for bundling in worker context |
| tests/specs/bundle/worker/main.ts | Test entry point that creates a worker for bundle testing |
| tests/specs/bundle/worker/worker.ts | Worker implementation that performs bundling and verifies the result |
| tests/specs/bundle/worker/main.ts.out | Expected test output showing successful bundling in worker |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kuboon
force-pushed
the
fix/bundle-in-worker
branch
from
November 17, 2025 09:32
83cfe38 to
fb87326
Compare
kuboon
force-pushed
the
fix/bundle-in-worker
branch
from
November 17, 2025 09:45
fb87326 to
797c284
Compare
bartlomieju
pushed a commit
that referenced
this pull request
Jan 22, 2026
Currently, `Deno.bundle` throws exception in a `Worker`.
```
error: Uncaught (in worker "") (in promise) Error: default BundleProvider does not do anything
```
This PR passes the clone of BundleProvider to workers.
---
minimum reproduction:
```ts
#! /usr/bin/env -S deno run --allow-read=. --unstable-bundle
if (typeof WorkerGlobalScope === "undefined") {
const worker = new Worker(import.meta.url, { type: "module" });
worker.onmessage = () => Deno.exit();
} else {
await Deno.bundle({
entrypoints: [import.meta.url],
write: false
});
postMessage("done");
}
```
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.
Currently,
Deno.bundlethrows exception in aWorker.This PR passes the clone of BundleProvider to workers.
minimum reproduction: