Skip to content

fix: embed capability limit in errors (#99) - #102

Open
agent-think[bot] wants to merge 1 commit into
mainfrom
fix/issue-99-1786620485
Open

fix: embed capability limit in errors (#99)#102
agent-think[bot] wants to merge 1 commit into
mainfrom
fix/issue-99-1786620485

Conversation

@agent-think

@agent-think agent-think Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Requested by @aron-cf

Closes #99

capabilitiesModule() in packages/computer/src/backends/worker-javascript/module-graph.ts:239 built the request-size error inside generated source. Although nested template interpolation currently produces the configured value, the source still looked like a runtime placeholder and had no regression coverage.

This change creates the complete message at build time and inserts it with JSON.stringify(). The generated Dynamic Worker module now unambiguously contains a quoted literal such as "Workspace capability request exceeds 256 bytes.", while preserving safe JavaScript string escaping.

The regression test captures the loader module map for maxCapabilityBytes: 256 and checks that the generated capability module contains the configured value and no maxCapabilityBytes placeholder. This follows the earlier investigation in the issue comment, which found that current interpolation works but recommended retaining this regression test.

Verified with npm run check, npm run typecheck --workspace @cloudflare/computer, and npm test --workspace @cloudflare/computer (all 61 main test files and the four configured Worker suites passed). A local Worker demo using the packed build also returned Workspace capability request exceeds 256 bytes. for an oversized node:fs/promises write.

Demo deployment skipped: Dynamic Workers require a paid Workers plan, while the temporary preview account used for demos rejected the Worker Loader binding with Cloudflare API error 10195. The local demo used the packed @cloudflare/computer build from this branch.

🤖 generated by the pr-agent — please review carefully

Generate the capability size error as a quoted literal so the configured
limit is fixed in the Dynamic Worker module. Cover the generated source to
keep the user-facing value visible.
@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fcb3977

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@cloudflare/computer Patch
@cloudflare/dofs Patch
@cloudflare/computer-rpc Patch
@cloudflare/computerd Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Aug 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@cloudflare/computer@102

commit: fcb3977

@yunaremaia yunaremaia left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified this PR locally. Solid change.

What I checked:

  1. Built the @cloudflare/dofs and @cloudflare/computer-rpc workspaces and ran worker-javascript.test.ts on this branch: 31/31 tests pass, including the new regression test.
  2. Counterfactual check: I reverted module-graph.ts to the main version (keeping only the new test) and the suite still passes — consistent with the analysis in #99 that the literal ${maxCapabilityBytes} does not leak at runtime today, because the message line lives inside the outer template literal in capabilitiesModule, so the placeholder gets interpolated regardless of the inner double quotes.

Assessment: This is sound defensive hardening rather than a fix for an active bug: it removes the fragile nested-interpolation pattern and pins the generated message with an explicitly escaped string via JSON.stringify, while the regression test locks the contract (generated module must contain the real limit and never the raw placeholder name). Changeset present, test is cheap (loader-mock based). Nothing blocking.

One minor, non-blocking note: the test asserts on generated module text via the loader mock — if the loader contract ever changes, load.mock.calls[0]?.[0].modules[...] will need updating. A short comment in the test explaining what it pins would help future contributors.

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.

Worker JavaScript capability size error prints a literal ${maxCapabilityBytes}

1 participant