-
-
Notifications
You must be signed in to change notification settings - Fork 379
feat: Add stream autoCancellation configuration option for streams #1521
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -600,5 +600,6 @@ const handleResponse = createResponseHandler({ | |
|
|
||
| const handleStream = createStreamHandler({ | ||
| mapResponse, | ||
| mapCompactResponse | ||
| mapCompactResponse, | ||
| streamOptions: {} | ||
| }) | ||
|
Comment on lines
601
to
605
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify that ElysiaConfig.stream is propagated to this handler. The Run the following script to check if there's a code path that passes the config from ElysiaConfig to the handlers: 🏁 Script executed: #!/bin/bash
# Search for where ElysiaConfig.stream is accessed and passed to handlers
rg -n -C3 "config\.stream|\.stream\s*\?" --type=ts -g '!test/**' -g '!node_modules/**'Length of output: 0 I'll conduct a more comprehensive search to trace how configuration flows through the codebase. The initial pattern search produced no results, so I need a broader investigation. I need to examine the actual codebase to understand the configuration flow. Let me search more broadly in the handler file and find where the configuration is passed. Length of output: 296 🏁 Script executed: #!/bin/bash
# Search for createStreamHandler definition and calls
rg -n "createStreamHandler" --type=ts -g '!node_modules/**' -B2 -A5Length of output: 4601 🏁 Script executed: #!/bin/bash
# Find ElysiaConfig type definition
rg -n "interface ElysiaConfig|type ElysiaConfig" --type=ts -g '!node_modules/**' -A20Length of output: 802 🏁 Script executed: #!/bin/bash
# Search for how stream config is used across the codebase
rg -n "stream\s*:" --type=ts -g '!node_modules/**' -C2 | head -50Length of output: 3617 🏁 Script executed: #!/bin/bash
# Find where the handler function is called/created with config
rg -n "createStreamHandler\s*\(" --type=ts -g '!node_modules/**' -B5 -A10Length of output: 3789 I need to verify the complete ElysiaConfig definition to see if a Length of output: 2774 🏁 Script executed: #!/bin/bash
# Search for stream property in ElysiaConfig
rg -n "stream" src/types.ts -C3Length of output: 2050 🏁 Script executed: #!/bin/bash
# Check how handlers are instantiated and if config is passed at runtime
rg -n "handleStream|handleResponse" src/adapter/web-standard/handler.ts -C5Length of output: 3649 🏁 Script executed: #!/bin/bash
# Look for where ElysiaConfig is used in handler initialization
rg -n "ElysiaConfig" src/adapter/web-standard/handler.ts -C3Length of output: 0 Pass ElysiaConfig.stream configuration to createStreamHandler in both adapters. ElysiaConfig.stream defines an autoCancellation property (lines 174-182 of src/types.ts), but the handlers in both adapters hardcode Both |
||
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.
🧩 Analysis chain
Verify that ElysiaConfig.stream is propagated to this handler.
The
streamOptionsis hardcoded to an empty object{}, which means theautoCancellationsetting will always fall back to the environment variable default. There's no visible mechanism to pass theElysiaConfig.streamconfiguration (defined insrc/types.tslines 171-184) to this handler.Run the following script to check if there's a code path that passes the config from ElysiaConfig to the handlers:
🏁 Script executed:
Length of output: 0
I need to investigate this more thoroughly with targeted searches. The initial pattern returned no results, so let me try different approaches to understand how the configuration flows.
Let me search the actual codebase to examine the ElysiaConfig definition and handler implementation.
Length of output: 1130
🏁 Script executed:
Length of output: 231
🏁 Script executed:
Length of output: 4831
I need to see the full ElysiaConfig definition and find where the stream property is defined, plus understand how the handlers are invoked with configuration.
Length of output: 2774
🏁 Script executed:
Length of output: 5489
🏁 Script executed:
Length of output: 517
I need to find where these handlers are exported and how the Elysia class uses them with the configuration.
Length of output: 0
🏁 Script executed:
Length of output: 2891
🏁 Script executed:
Length of output: 1644
Let me search for the main Elysia class and how it uses these handler modules:
Length of output: 75
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 0
Let me search the repository structure more broadly:
Length of output: 1222
🏁 Script executed:
Length of output: 847
🏁 Script executed:
Length of output: 187196
ElysiaConfig.stream is not propagated to handler instantiation.
ElysiaConfig defines a
streamproperty (src/types.ts:174) withautoCancellation?: boolean, but the stream handlers are instantiated at module load time with hardcoded empty options. At src/adapter/bun/handler.ts:568-572 and src/adapter/web-standard/handler.ts:601-605,createStreamHandleris called withstreamOptions: {}. The createStreamHandler function falls back to environment variable defaults when streamOptions is empty, meaning instance-level config is ignored entirely.To fix this,
streamOptionsmust be populated from the Elysia instance's config at handler composition time, not at module load time. This likely requires refactoring the handler instantiation to be request-aware or instance-aware rather than module-level singletons.🤖 Prompt for AI Agents