Fix CBOR decoder "keyDecoder is undefined" error with runtime patch #928
+1,805
−1,211
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 fixes a critical runtime error where CBOR decoders fail with "Cannot read properties of undefined (reading 'decode')" due to a missing
keyDecoder
property.Problem
Users encounter this error when using CBOR functionality:
The issue occurs because
this.keyDecoder
isundefined
in theCborDecoderBase
constructor.Root Cause
The problem stems from a re-export issue in the
@jsonjoy.com/util
package. The file@jsonjoy.com/util/lib/buffers/utf8/sharedCachedUtf8Decoder.js
uses:However,
tslib.__exportStar
intentionally skips thedefault
export. Since the original module exports the shared UTF8 decoder asdefault
, it gets lost during re-export, makingsharedCachedUtf8Decoder_1.default
undefined.Solution
This PR implements a runtime patch that:
default
export is missing from the re-exported module@jsonjoy.com/buffers
packagedefault
exportUsage
The fix works automatically - no code changes required:
CLI tools also work correctly:
Testing
Added comprehensive regression tests that verify:
Backward Compatibility
The fix is completely backward compatible and requires no changes to existing code. The patch only activates when the problematic re-export is detected.
Fixes #925.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.