Repository navigation
Preserve the name of error types that can't be reconstructed - #289
dinasaur404 wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 87517dd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
commit: |
|
This pull request was not reviewed automatically because its author does not have write access to this repository. A maintainer with write access can start a review by commenting |
Errors whose type capnweb can't reconstruct (anything other than the built-in error classes) arrive as plain
Errorwithname: "Error". Own properties likecodealready survive, but the original name is lost. workerd keeps the name when it passes these errors between Workers, so capnweb behaves differently from the platform it runs alongside.This shows up in Wrangler's remote bindings, which use capnweb between the local and remote proxy workers. A Cloudflare Artifacts binding throws
ArtifactsErrorin production, but inwrangler devwithremote: truethe error arrives asError.Change
When the receiver falls back to
Errorfor an unknown type, setnameto the sender's value as a non-enumerable own property. The object is still a realErrorwithError.prototype, soinstanceofchecks and type safety don't change.Names that resolve to
Object.prototypemembers (for exampleconstructoror__proto__) still becomeError, so the existing type-confusion guarantees and test still hold.Testing
ArtifactsErrorsubclass withcodeandnumericCoderound-trips with its name, staysinstanceof ErrorwithError.prototype, keepsnameout ofObject.keys, andString(error)gives"ArtifactsError: …". It fails without the change.nodeproject: 422 passed.workerdproject: 225 passed. The browser projects weren't run locally because Playwright browsers aren't installed.tsc --noEmitreports the same 44 errors asmain, none new.remote: true. Errors came back as{ name: "ArtifactsError", code: "NOT_FOUND", numericCode: 10200 }, identical to production.