Skip to content

feat(http): trace Bun.serve requests - #11269

Open
devin-ai-integration[bot] wants to merge 3 commits into
masterfrom
devin/1794856327-bun-serve
Open

devin-ai-integration[bot] wants to merge 3 commits into
masterfrom
devin/1794856327-bun-serve

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Part of experimental Bun support. Trace native Bun.serve requests through the existing HTTP server plugin and web helpers. Runtime changes are gated by process.versions.bun.

  • Create web.request spans with HTTP tags, distributed context extraction, configured header tags, error handling, and existing CORS propagation response-header behavior.
  • Instrument fetch callbacks and native function/method-map routes, using route keys for http.route. Preserve static Response routes on Bun's native fast path, without server tracing.
  • Connect CommonJS Hono's Fetch Request to the HTTP context for routed hono.request spans, including default-export applications.
  • Trace replacement fetch/routes/error handlers installed by server.reload, including Elysia's automatically reloaded native routes.
  • Record successful WebSocket upgrades as 101 without an error; finish client aborts with Node HTTP's default-status/no-invented-error semantics; retain request-local custom-error context when concurrent requests reuse an Error.
  • Avoid response-header copies unless injection changes headers, allocate an AbortController only for incoming-request security subscribers, and observe aborts only while asynchronous handlers are pending. Bypass handler adaptation when HTTP tracing is disabled programmatically.

Motivation

Native Bun servers bypass Node HTTP server events and otherwise produce no inbound server spans. Reuse the HTTP plugin rather than duplicate span, propagation, and header behavior.

Additional Notes

Validation

Bun 1.4.4 / Node v24.19.0, after merging current master without rebasing:

npm run test:integration:bun                                        41 passing
PLUGINS='http|hono' npm run test:plugins                             720 passing, 6 pending
PLUGINS=hono npm run test:instrumentations                          10 passing
mocha packages/dd-trace/test/plugins/plugin-structure.spec.js        191 passing
Changed-file ESLint                                               passed
npm run lint:editorconfig                                          passed

npm run lint still reports the initialized OpenFeature submodule's tools/ufc/rules-resources.test.mjs as uncovered by test globs. The same failure reproduces in the unchanged base checkout; no submodule or lint configuration change is included here.

Before/after regression proof: the new shared-error-context, WebSocket, client-abort, and static-fast-path tests all fail against the pre-fix implementation and pass with this update. The Elysia regression also exercises its normal .get('/users/:id').listen(...) startup, including automatic reload.

One intermediate run terminated with a native Bun SIGSEGV in the async-fetch test. Its cause is unclassified: the exact test subsequently passed 20/20 times on both the pre-fix and candidate revisions, and the final complete Bun suite passed. This is not being classified as an unrelated failure.

Reproducible performance measurement

Workload: loopback HTTP/1.1 GET /, two-byte hi body, 50,000 measured requests after 5,000 warmup requests, concurrency 20, five fresh-process trials per mode. Alternate mode order each round; report median requests/second. The Bun server and untraced Bun fetch client are separate processes; a Node driver provides a local trace-agent stub. Trace export is included for traced function handlers. Linux x64, Bun 1.4.4 for both server/client, Node v24.19.0 driver.

Baseline: pre-fix implementation at merge commit e0aa1a261 (original Bun implementation plus the same current master). Candidate: this update. Both runs use the identical benchmark script from this branch:

# Baseline checkout needs the same installed dependencies and real vendor/dist bundles.
node benchmark/bun-serve.js /path/to/pre-fix-checkout
node benchmark/bun-serve.js
# Optional overrides: ROUNDS=5 REQUESTS=50000 CONCURRENCY=20
Workload Baseline req/s Candidate req/s Change
Static Response, no tracer init 81,291 79,051 -2.8%
Static Response, tracer initialized 41,085 80,310 +95.5% (1.95x)
Static Response, HTTP disabled programmatically 81,540 80,779 -0.9%
Fetch callback, no tracer init 82,223 81,214 -1.2%
Fetch callback, HTTP tracing enabled 42,373 45,817 +8.1%
Fetch callback, HTTP disabled programmatically 80,784 81,143 +0.4%

Candidate static-route performance is within approximately 2% of its uninitialized control; unlike the baseline it performs no per-request JavaScript adaptation or cloning. These are local throughput measurements, not production latency estimates. The benchmark prints every trial as JSON for repeatability. Kept URL parsing readable rather than retaining an unproven manual-parser micro-optimization.

Scope / limitations

  • Static Response routes intentionally have no server span, distributed extraction, or tracing response-header injection, including static entries inside method maps. Use a function route when tracing is needed. HTML-bundle routes remain unsupported.
  • Hono route spans currently require require('hono'). Normal import { Hono } from 'hono' yields only the underlying web.request, without hono.request or a Hono route name. The default-export fixture imports Hono through CommonJS; ESM loader support is separate work and is not implemented here.
  • Elysia 1.4.32's native dynamic routes are covered as routed web.request spans through its server.reload path; this does not add Elysia-specific middleware spans.
  • Spans measure fetch/error-handler response readiness, not final socket flush or streamed-body completion. Streaming bodies remain untouched. WebSocket tracing covers the upgrade handshake, not messages or connection lifetime.
  • Bun's development-mode error page can include different stack metadata after wrapping; production error responses retain native handling. This does not enable native AppSec/IAST/profiling support on Bun.

CI status

Current snapshot: 579 passed, 1 failed, 1 queued, 52 cancelled, and 6 skipped. Bun runtime, HTTP/Hono, instrumentation, lint, and EditorConfig checks passed.

All Green exhausted its 30 polling attempts and cancelled three still-queued workflows: Serverless, System Tests, and Test Optimization. This is an aggregator timeout, not a Bun assertion failure. Team freeze guard remains queued.

The initial Event Hubs attempt had 30 connection-refused failures at 127.0.0.1:7071 immediately after its host-lock readiness signal. Its retry was cancelled while queued, so this failure remains unclassified rather than being labelled unrelated. The same job passed all 30 tests on the unchanged target branch. No unrelated test changes or skips were added.

Rerunning the three cancelled workflows was denied with Resource not accessible by integration; a maintainer needs to rerun them, then All Green after they finish. The previous revision also hit an All Green timeout; no merge or public-comment changes were made.

Link to Devin session: https://datadog-poc.devinenterprise.com/sessions/e0c443c51e3947ab94efea770d17a670
Open in Devin Desktop: https://datadog-poc.devinenterprise.com/desktop/session/e0c443c51e3947ab94efea770d17a670?variant=devin
Requested by: @eam1813

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@dd-octo-sts

dd-octo-sts Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 9.57 MB
Deduped: 10.32 MB
No deduping: 10.32 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.5.3 | 131.25 kB | 531.9 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.15%. Comparing base (c3b0f6f) to head (a4bd403).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #11269   +/-   ##
=======================================
  Coverage   99.15%   99.15%           
=======================================
  Files        1136     1136           
  Lines      188318   188381   +63     
  Branches       86       86           
=======================================
+ Hits       186729   186797   +68     
+ Misses       1589     1584    -5     
Flag Coverage Δ
ai-guard 63.33% <62.50%> (+<0.01%) ⬆️
apm-capabilities 55.17% <71.42%> (+0.01%) ⬆️
apm-integrations 81.93% <100.00%> (-0.01%) ⬇️
appsec 59.24% <71.42%> (+<0.01%) ⬆️
debugger 70.89% <100.00%> (-0.01%) ⬇️
instrumentation 60.17% <100.00%> (+0.05%) ⬆️
llmobs 82.52% <100.00%> (-0.01%) ⬇️
master-coverage 99.15% <100.00%> (?)
openfeature 68.07% <62.50%> (-0.01%) ⬇️
platform 68.15% <62.50%> (+<0.01%) ⬆️
profiling 66.52% <100.00%> (+<0.01%) ⬆️
serverless 66.67% <100.00%> (+0.01%) ⬆️
test-optimization 82.02% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 98.57% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: a4bd403 | Docs | View more details | Give us feedback!

@pr-commenter

pr-commenter Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-11-23 19:12:13

Comparing candidate commit a4bd403 in PR branch devin/1794856327-bun-serve with baseline commit c3b0f6f in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2465 metrics, 22 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-20

  • unstable max_rss_usage [-50.630MB; +68.063MB] or [-20.374%; +27.389%]

scenario:appsec-iast-with-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-33.210MB; +9.872MB] or [-9.449%; +2.809%]

scenario:appsec-iast-with-vulnerability-iast-enabled-default-config-26

  • unstable max_rss_usage [-17.103MB; +23.167MB] or [-5.549%; +7.517%]

scenario:debugger-enabled-but-breakpoint-not-hit-20

  • unstable cpu_user_time [-940.098ms; +1390.391ms] or [-10.011%; +14.806%]
  • unstable execution_time [-940.372ms; +1388.909ms] or [-10.009%; +14.783%]
  • unstable instructions [-9.7G instructions; +15.5G instructions] or [-8.372%; +13.325%]
  • unstable throughput [-3249806.046op/s; +2245898.504op/s] or [-12.111%; +8.370%]

scenario:debugger-enabled-but-breakpoint-not-hit-24

  • unstable cpu_user_time [-377.574ms; +545.972ms] or [-4.263%; +6.165%]
  • unstable execution_time [-376.024ms; +545.292ms] or [-4.245%; +6.155%]

scenario:debugger-line-probe-with-snapshot-default-26

  • unstable max_rss_usage [-13.864MB; +5.891MB] or [-7.445%; +3.163%]

scenario:encoders-0.4-immediate-flush-20

  • unstable cpu_user_time [-1089.002ms; +1736.474ms] or [-8.495%; +13.546%]
  • unstable execution_time [-1093.501ms; +1746.338ms] or [-8.492%; +13.563%]
  • unstable throughput [-2119.856op/s; +1326.819op/s] or [-11.810%; +7.392%]

scenario:openfeature-initialization-configuration-20

  • unstable max_rss_usage [-4482.034KB; +4435.125KB] or [-5.929%; +5.867%]

scenario:openfeature-initialization-configuration-26

  • unstable cpu_user_time [-133.902ms; +105.554ms] or [-7.882%; +6.213%]
  • unstable execution_time [-135.401ms; +105.152ms] or [-7.668%; +5.955%]
  • unstable throughput [-29597.698op/s; +39778.231op/s] or [-5.130%; +6.895%]

scenario:openfeature-initialization-error-20

  • unstable max_rss_usage [-6.074MB; +3.308MB] or [-7.926%; +4.317%]

scenario:openfeature-scale-full-26

  • unstable max_rss_usage [-33207.881KB; +32067.881KB] or [-14.669%; +14.165%]

scenario:plugin-aws-sdk-lambda-inject-with-context-24

  • unstable cpu_user_time [-93.175ms; +172.450ms] or [-3.674%; +6.799%]
  • unstable execution_time [-92.311ms; +173.131ms] or [-3.617%; +6.783%]

scenario:plugin-graphql-long-with-depth-on-max-26

  • unstable max_rss_usage [-25.964MB; +41.643MB] or [-13.870%; +22.247%]

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T19:01:57.734384Z a4bd403 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment on lines +29 to +31
if (process.versions.bun && !disabledInstrumentations.has('http')) {
require('../bun')
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine for now but of course once we support more than one Bun feature the http disabled check will need to be removed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[babysit-pr] Agreed, no change for now. This gate is scoped to bun-serve because it only produces HTTP spans. Any future Bun-native instrumentation should get its own gate keyed on its own integration name rather than reusing this one.

@pabloerhard pabloerhard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the naming of the files is to general and we should consider renaming the following files:

packages/datadog-instrumentations/src/helpers/bun.js → packages/datadog-instrumentations/src/helpers/bun-requests.js

packages/datadog-instrumentations/src/bun.js → packages/datadog-instrumentations/src/bun-serve.js

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7251934aa

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (!start.hasSubscribers) return fetch.apply(this, arguments)

const url = new URL(request.url)
const address = server.requestIP(request)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle server.fetch calls without a second callback argument

When an application invokes server.fetch(request) directly, Bun can invoke the fetch callback without the second server argument, so this dereference throws before the application handler executes. Reproduced on the available Bun 1.2.14 runtime: the uninstrumented call returns its normal response, whereas loading this instrumentation with the start channel enabled produces TypeError: undefined is not an object (evaluating 'server.requestIP'). Network requests do supply the argument, so the network-only fixtures miss this regression. Resolve the server from the callback receiver when necessary, or safely omit the peer-address lookup for direct dispatch. This also violates the instrumentation-failure isolation requirement in AGENTS.md.

AGENTS.md reference: AGENTS.md:L104-L106

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[babysit-pr] Fixed in 792ade3. Confirmed on Bun 1.4.5 that server.fetch(request) calls the handler without the server argument while still binding the server as this. The instrumentation now uses server ?? this for requestIP, passes the application's original arguments through unchanged, and defaults the Host header from the request URL so http.url stays valid. Added an integration test for direct dispatch, which fails with the reported TypeError without the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matbrwn
matbrwn force-pushed the devin/1794856327-bun-serve branch from a725193 to b2f7b58 Compare November 23, 2026 17:54
Bun omits the server argument when an application calls server.fetch(request) directly, so resolve it from the bound receiver, and default the Host header so the span URL stays valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matbrwn

matbrwn commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

[babysit-pr] @pabloerhard the renames you suggested are in: helpers/bun.js is now helpers/bun-requests.js, and bun.js is now bun-serve.js.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 792ade3ced

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +118 to +122
if (!finished) {
errors.set(request, {
error,
// Bun invokes its error callback outside the fetch handler's async context.
handle: AsyncResource.bind(function () {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Finish direct-dispatch failures without awaiting Bun's error callback

When server.fetch(request) throws or rejects, Bun propagates the failure directly without invoking the server's error callback. Consequently, this entry is never removed and the request span never finishes. Reproduced with Bun 1.2.14 using this instrumentation: direct dispatch publishes start/error/exit but no finish. Repeated failures retain requests and their bound contexts indefinitely; if a subsequent network request throws the same Error object, the error callback selects the stale direct-dispatch entry and runs in the wrong request context. Handle direct-dispatch failures separately, completing their spans while preserving the original throw/rejection.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[babysit-pr] Fixed in a4bd403. Confirmed on Bun 1.4.5 that a throwing or rejecting direct server.fetch(request) call never reaches the error callback. Direct dispatch (no server argument) now finishes its span as soon as the handler fails, without storing an entry for the error callback, and still rethrows the original error to the caller. Added integration tests for the sync and async cases that check the 500 span, its error message, and that the caller still sees the original error.

const wrapHandler = (fetch, route) => function (request, server) {
if (!start.hasSubscribers) return fetch.apply(this, arguments)

const url = new URL(request.url)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard URL parsing before invoking the application handler

When an incoming request contains a malformed Host header such as [, Bun can supply a request.url that the WHATWG URL parser rejects. Reproduced on Bun 1.2.14: an uninstrumented handler receives this request and returns 200, whereas enabling this wrapper makes new URL(request.url) throw and returns 500 without invoking the application handler. Since this parsing occurs outside the guarded handler execution, tracing changes the application's behavior for these inputs. Fall back to invoking the original handler without instrumentation when the URL cannot be parsed.

AGENTS.md reference: AGENTS.md:L104-L106

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[babysit-pr] Fixed in a4bd403. Confirmed on Bun 1.4.5 that Host headers like [, a b, or an empty value give a request.url the URL parser rejects, while an untraced handler still returns 200. The wrapper now uses URL.parse and calls the original handler untraced when it returns null, which avoids a try/catch on the hot path. Added an integration test that sends Host: [ over a raw socket and expects the application's 200 response.

Bun rethrows direct server.fetch() failures without calling its error callback, so finish those spans immediately instead of keeping them for a callback that never runs. Requests whose URL cannot be parsed now reach the application untraced instead of failing before the handler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4bd403117

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (url === null) return fetch.apply(this, arguments)
// Direct `server.fetch(request)` calls omit the server argument but still bind the server as `this`.
const direct = server === undefined
const address = (server ?? this).requestIP(request)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow direct dispatch after the Bun server has stopped

When server.fetch(request) is called after server.stop(true), the callback can receive neither the server argument nor a bound receiver, so this dereference throws before the application handler runs. Fresh evidence beyond the earlier direct-dispatch finding: on the available Bun 1.2.14 runtime, stopping the server first leaves uninstrumented direct dispatch working normally, but the current wrapper throws TypeError evaluating (server ?? this).requestIP. Safely omit the peer-address lookup when neither server reference is available, preserving direct dispatch for in-process requests after shutdown.

AGENTS.md reference: AGENTS.md:L104-L106

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[babysit-pr] No change: this does not reproduce on the Bun this repo tests. On the pinned Bun 1.4.4 (and 1.4.5), calling server.fetch(request) after server.stop(true) still binds the server as this, and requestIP returns null, so the wrapper reaches the application handler normally. The failure needs Bun 1.2.14, which CI does not run. A guard for it could not be covered by a test here, and AGENTS.md asks for supported-source proof before adding defenses like this. If we decide to support older Bun releases, this is a one-character change (?.requestIP) along with a CI job on that version.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants