-
Notifications
You must be signed in to change notification settings - Fork 134
IETF: Fix PUBLISH_DONE encoding. #674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughPublishDone was moved in TypeScript from Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
js/moq/src/ietf/connection.ts(2 hunks)js/moq/src/ietf/control.ts(2 hunks)js/moq/src/ietf/ietf.test.ts(2 hunks)js/moq/src/ietf/publish.ts(1 hunks)js/moq/src/ietf/publisher.ts(1 hunks)js/moq/src/ietf/subscribe.ts(0 hunks)js/moq/src/ietf/subscriber.ts(1 hunks)rs/moq/src/ietf/publish.rs(2 hunks)rs/moq/src/ietf/publisher.rs(2 hunks)
💤 Files with no reviewable changes (1)
- js/moq/src/ietf/subscribe.ts
🧰 Additional context used
📓 Path-based instructions (1)
rs/**/src/**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
Write Rust tests integrated within source files (unit tests alongside code).
Files:
rs/moq/src/ietf/publisher.rsrs/moq/src/ietf/publish.rs
🧬 Code graph analysis (3)
rs/moq/src/ietf/publish.rs (1)
js/moq/src/ietf/publish.ts (6)
w(42-58)w(124-128)w(160-165)r(68-88)r(138-143)r(175-182)
js/moq/src/ietf/publish.ts (3)
js/moq/src/ietf/publisher.ts (2)
requestId(114-131)requestId(140-174)js/moq/src/stream.ts (2)
Writer(217-303)Reader(53-214)js/moq/src/ietf/control.ts (1)
Message(63-63)
js/moq/src/ietf/ietf.test.ts (2)
js/moq/src/ietf/connection.ts (2)
msg(134-207)msg(213-218)js/moq/src/ietf/publish.ts (1)
PublishDone(147-183)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Check
🔇 Additional comments (9)
rs/moq/src/ietf/publisher.rs (1)
112-129: Looks good—stream_count wired up
Settingstream_counton both success and error paths keeps the wire format in sync with the updated struct. Thanks for adding the TODO for the real count.js/moq/src/ietf/ietf.test.ts (1)
6-118: Tests updated correctly
ImportingPublishDonefrom its new home and exercising encode/decode directly keeps coverage intact.js/moq/src/ietf/subscriber.ts (1)
10-12: Import shuffle makes sense
Switching to type-only imports frompublish.tsmatches the symbol relocation without altering runtime behavior.js/moq/src/ietf/control.ts (1)
5-39: Control registry stays consistent
PullingPublishDonefrompublish.tskeeps the message map aligned with the new class location.rs/moq/src/ietf/publish.rs (3)
120-125: LGTM! Proper field addition to PublishDone.The new
stream_countfield is correctly added to the struct with appropriate type (u64) and visibility (pub), consistent with the other fields. The placement betweenstatus_codeandreason_phrasealigns with the protocol encoding order.
130-135: LGTM! Encoding implementation is correct.The
stream_countfield is properly encoded in the correct position within the message sequence. The encoding order (request_id → status_code → stream_count → reason_phrase) matches the protocol specification and struct layout.
137-149: LGTM! Decoding implementation is correct.The
stream_countfield is properly decoded in the correct sequence, and the decoded value is correctly assigned to the struct field. The decoding order matches the encoding order, ensuring protocol compatibility.js/moq/src/ietf/publisher.ts (1)
16-17: LGTM! Clean import reorganization.The
PublishDoneimport has been correctly moved fromsubscribe.tstopublish.ts, which improves module cohesion by grouping publish-related types together. The refactoring is clean with no functional changes.js/moq/src/ietf/connection.ts (1)
11-11: LGTM! Consistent import reorganization.The
PublishDoneimport has been correctly relocated fromsubscribe.tstopublish.ts, matching the module reorganization pattern applied across the codebase. This change improves module cohesion with no functional impact.Also applies to: 22-22
| requestId: bigint; | ||
| statusCode: number; | ||
| reasonPhrase: string; | ||
|
|
||
| constructor(requestId: bigint, statusCode: number, reasonPhrase: string) { | ||
| this.requestId = requestId; | ||
| this.statusCode = statusCode; | ||
| this.reasonPhrase = reasonPhrase; | ||
| } | ||
|
|
||
| async #encode(w: Writer): Promise<void> { | ||
| await w.u62(this.requestId); | ||
| await w.u62(BigInt(this.statusCode)); | ||
| await w.u62(BigInt(0)); // stream_count = 0 (unsupported) | ||
| await w.string(this.reasonPhrase); | ||
| } | ||
|
|
||
| async encode(w: Writer): Promise<void> { | ||
| return Message.encode(w, this.#encode.bind(this)); | ||
| } | ||
|
|
||
| static async decode(r: Reader): Promise<PublishDone> { | ||
| return Message.decode(r, PublishDone.#decode); | ||
| } | ||
|
|
||
| static async #decode(r: Reader): Promise<PublishDone> { | ||
| const requestId = await r.u62(); | ||
| const statusCode = Number(await r.u62()); | ||
| await r.u62(); // ignore stream_count | ||
| const reasonPhrase = await r.string(); | ||
|
|
||
| return new PublishDone(requestId, statusCode, reasonPhrase); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve the stream_count field instead of hard‑coding zero
Right now we always transmit stream_count = 0 and drop whatever value the peer sent. That makes PublishDone messages non‑round‑trippable and prevents us from honoring draft‑14’s stream budgeting semantics (the Rust side already exposes the field). Please surface stream_count on the class, keep it when decoding, and use that value when encoding so we don’t lose the information.
requestId: bigint;
statusCode: number;
+ streamCount: bigint;
reasonPhrase: string;
- constructor(requestId: bigint, statusCode: number, reasonPhrase: string) {
+ constructor(requestId: bigint, statusCode: number, reasonPhrase: string, streamCount: bigint = 0n) {
this.requestId = requestId;
this.statusCode = statusCode;
+ this.streamCount = streamCount;
this.reasonPhrase = reasonPhrase;
}
async #encode(w: Writer): Promise<void> {
await w.u62(this.requestId);
await w.u62(BigInt(this.statusCode));
- await w.u62(BigInt(0)); // stream_count = 0 (unsupported)
+ await w.u62(this.streamCount);
await w.string(this.reasonPhrase);
}
@@
static async #decode(r: Reader): Promise<PublishDone> {
const requestId = await r.u62();
const statusCode = Number(await r.u62());
- await r.u62(); // ignore stream_count
+ const streamCount = await r.u62();
const reasonPhrase = await r.string();
- return new PublishDone(requestId, statusCode, reasonPhrase);
+ return new PublishDone(requestId, statusCode, reasonPhrase, streamCount);
}🤖 Prompt for AI Agents
In js/moq/src/ietf/publish.ts around lines 150–182, the PublishDone class
currently hard‑codes stream_count = 0 and drops the peer value; add a
streamCount property (type bigint), accept it in the constructor, store it, read
it when decoding (assign the result of r.u62() to streamCount instead of
ignoring), and use that stored streamCount when encoding (write this.streamCount
via w.u62). Ensure constructor signature and the returned new PublishDone(...)
call include streamCount and keep types consistent (bigint) so PublishDone
round‑trips the stream_count field.
Summary by CodeRabbit