fix(producer): guard fileServer.close in all render cleanup paths#1406
Open
calcarazgre646 wants to merge 2 commits into
Open
fix(producer): guard fileServer.close in all render cleanup paths#1406calcarazgre646 wants to merge 2 commits into
calcarazgre646 wants to merge 2 commits into
Conversation
`plan()` and `renderChunk()` both close the probe/chunk file server with a bare `fileServer.close()` in their cleanup sequence. `FileServerHandle.close` tears down the underlying http.Server, whose `close()` throws `ERR_SERVER_NOT_RUNNING` if the server was already torn down (for example a cancellation path that closed it once already). An unguarded throw there escapes the cleanup and masks the original plan/render result, exactly the failure the adjacent probe-session close already guards against with a try/catch (its comment even spells this out). Add `closeFileServerSafely`, which wraps the close in a try/catch and logs, and route both cleanup sites through it so the two stay consistent and a throwing close can never mask the real result. Covered by unit tests for both the throwing and happy paths.
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.
Problem
fileServer.close()is called bare (no try/catch) in several render cleanup paths.FileServerHandle.closetears down the underlying http.Server, whoseclose()throwsERR_SERVER_NOT_RUNNINGif the server was already torn down (for example a cancellation path that already closed it once). An unguarded throw escapes the cleanup and masks the original plan/render result.The immediately adjacent probe-session close already guards against exactly this, and its comment spells it out:
The file-server closes next to it were left unguarded. There were three:
distributed/plan.ts(probe cleanup),distributed/renderChunk.ts(finally block),renderOrchestrator.ts(the in-process render success path, right before the assemble stage — a throw here would skip assembly and mask the result).Fix
Add
closeFileServerSafely(fileServer, label, log)infileServer.ts, which wraps the close in a try/catch and logs, and route all three sites through it.Tests
Unit tests for
closeFileServerSafely: a throwingclose()is swallowed and logged (does not propagate), and the happy path closes exactly once with no warning.plantest suite stays green. (TherenderChunkbyte-identical determinism test is host-Chrome dependent and soft-skips outsideDockerfile.test.)