fix: integration test readiness for fibp#7
Merged
vieiralucas merged 3 commits intomainfrom Mar 26, 2026
Merged
Conversation
…ructure fix auth payload encoding: server expects raw utf-8 key bytes, not u16+bytes fix error frame decoding: server sends raw utf-8, not u16 code + u16 len + msg fix consume delivery decoding: server push frames omit queue field (not in wire format) fix consume stream dispatch: push frames use corr_id=0 and flag_push routing, not corr_id-based routing; openConsumeStream awaits subscribe ack then registers global push handler for subsequent flag_push frames fix batcher connection: batcher now holds async getConn() so enqueue() can submit synchronously before close()/drain() marks batcher closed fix proto resolvepath: absolute paths were being double-prefixed with proto dir add fileParallelism: false to vitest config to prevent port collisions when multiple test files start fila-server instances concurrently
There was a problem hiding this comment.
2 issues found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/transport.ts">
<violation number="1" location="src/transport.ts:522">
P1: Race condition: PUSH frames received in the same TCP chunk as the subscribe ACK will be silently dropped because `this.pushHandler` is registered after the `await`.</violation>
<violation number="2" location="src/transport.ts:556">
P1: Missing guard for concurrent consume streams. Opening a second stream on the same connection silently overwrites `this.pushHandler`, causing the first stream to hang and misrouting its messages.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…bscribe - throw FilaError if openConsumeStream is called while a stream is already active, preventing silent pushHandler overwrite - register pushHandler before awaiting the subscribe ack so PUSH frames arriving in the same TCP chunk as the ACK are buffered rather than dropped - on subscribe request failure, clear pushHandler so the connection remains usable for future streams
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
What was broken and why
1. Auth payload (
encodeAuthPayload)JS sent
u16 length + key bytes; server reads raw key bytes only. Auth always failed.2. Error frame decoding (
decodeErrorPayload)JS expected
u16 code + u16 msglen + msg; server sends raw UTF-8 message string. Error codes were garbage (e.g. 26990 = bytes "in" from "invalid"). Now decodes raw string and maps known message substrings to typed error codes.3. Consume delivery wire format (
decodeConsumeDelivery)JS decoded
id + queue + fairness_key + ...; server encodesid + fairness_key + ...(no queue field in push frame). All consumed messages had garbled data.4. Consume stream dispatch (
openStream→openConsumeStream)JS registered a corrId-based stream handler but server push frames use
corrId = 0withFLAG_PUSH. The subscribe ack frame (corrId = N, no FLAG_PUSH) was incorrectly interpreted as "stream ended," closing the consumer immediately. Replaced with two-phase approach: await subscribe ack as a normal request, then register a global push handler for FLAG_PUSH frames.5. Batcher connection lifecycle
Batcher held a sync
getConnSync()callback;Client.enqueue()had anawait getConn()beforebatcher.submit(). A concurrentclose()/drain()could mark the batcher closed before submit ran. Fixed by making the batcher hold an asyncgetConn()callback soenqueue()submits synchronously without any prior await.6. Proto
resolvePathdouble-prefix (test/helpers.ts)protobufjscallsresolvePath("", "/absolute/path")for the initialloadSynccall. The custom resolver prependedPROTO_DIRagain, producing/proto/dir//proto/dir/file.proto. Addedpath.isAbsoluteguard.7. Port collision in parallel test runs (
vitest.config.ts)Multiple test workers called
findFreePort()simultaneously, found the same port (TOCTOU), and both tried to start fila-server on it. AddedfileParallelism: falseto run test files sequentially.Test plan
npm run lint— passesnpm run typecheck— passesnpm test— 46/50 pass locally; 4 TLS tests skip (local binary built without rustls crypto provider, CI binary has it configured)🤖 Generated with Claude Code
Summary by cubic
Fixes FIBP wire format mismatches and push‑stream routing to match the Rust server, unblocking integration tests. Hardens consume streaming to avoid dropped pushes and block concurrent streams.
ErrCode.id + fairness_key + ...).FLAG_PUSHframes withcorrId=0; expose cancel; reject concurrent streams.getConn()soenqueue()queues before any await, avoiding close/drain races.protobufjsresolver; setvitestfileParallelism: falseto avoid port collisions.Written for commit 8f3541d. Summary will update on new commits.