Address review comments: type safety and runtime guards#194
Closed
baelter wants to merge 2 commits intomessage-codec-registryfrom
Closed
Address review comments: type safety and runtime guards#194baelter wants to merge 2 commits intomessage-codec-registryfrom
baelter wants to merge 2 commits intomessage-codec-registryfrom
Conversation
…add runtime guard
- Remove the second `publish(body: Serializable, { contentType })` overload from
AMQPQueue, AMQPExchange, AMQPRPCClient.call(), and AMQPSession.rpcCall(). These
overloads were accessible on plain (non-codec) sessions, allowing non-Body values
to pass type checking but fail at runtime. The `PublishBody<C>` conditional type
already resolves to `Serializable` for codec sessions, so the first overload
covers both cases correctly.
- Add a runtime guard in `AMQPSession.encodeBody()` that throws a clear error when
a non-Body value is passed without a codec registry, instead of silently casting
with `as Body`.
- Fix flaky codec callback test by replacing `setTimeout(100)` polling with a
promise that resolves on message delivery.
- Fix incorrect `CodecMode` import path in test file.
- Fix type-unsafe cast in `withCodecSession` test helper.
https://claude.ai/code/session_013dVmJ9E1SChBtX7oFs3vmb
Member
Author
|
Superseded. Addressing the review feedback directly on the main branch with a simpler approach: dropping the generic from consume-side classes entirely. |
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.
Summary
Serializableoverloads fromAMQPQueue.publish(),AMQPExchange.publish(),AMQPRPCClient.call(), andAMQPSession.rpcCall()that were accessible on plain (non-codec) sessions, defeating TypeScript compile-time safetyAMQPSession.encodeBody()that throws a clear error for non-Body values when no codec registry is configured, instead of silently casting withas BodysetTimeout(100)polling with promise-based message deliveryCodecModeimport path and unsafe type cast in test helperTest plan
npm run typecheck)test/amqp-codec-registry.ts)test/amqp-session.ts)https://claude.ai/code/session_013dVmJ9E1SChBtX7oFs3vmb