Skip to content

fix(elysia): avoid AsyncLocalStorage probe on Bun - #497

Open
adrian-scehura wants to merge 1 commit into
HugoRCD:mainfrom
adrian-scehura:adrian/fix-bun-async-storage-probe
Open

fix(elysia): avoid AsyncLocalStorage probe on Bun#497
adrian-scehura wants to merge 1 commit into
HugoRCD:mainfrom
adrian-scehura:adrian/fix-bun-async-storage-probe

Conversation

@adrian-scehura

@adrian-scehura adrian-scehura commented Aug 3, 2026

Copy link
Copy Markdown

Avoid calling AsyncLocalStorage.enterWith(undefined) while detecting support on Bun because the probe replaces bun:test's active lifecycle context. Bun continues using its native implementation, while runtimes with missing or throwing implementations still receive the existing fallback.

Adds a regression test ensuring Bun detection does not invoke enterWith().

Closes #496

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue that could cause test lifecycle hooks to stall in Bun environments.
    • Improved runtime capability detection to avoid unnecessary side effects.
  • Tests
    • Added regression coverage for Bun-specific behavior.
    • Improved test cleanup to prevent mocked global state from leaking between tests.

@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9d9df53

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
evlog Patch
@evlog/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@adrian-scehura is attempting to deploy a commit to the HRCD Projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0ac71c96-768a-4695-99cf-4cb925dcac31

📥 Commits

Reviewing files that changed from the base of the PR and between bb465f8 and 9d9df53.

📒 Files selected for processing (3)
  • .changeset/safe-context-probe.md
  • packages/evlog/src/shared/asyncStorageScope.ts
  • packages/evlog/test/shared/asyncStorageScope.test.ts

📝 Walkthrough

Walkthrough

The AsyncLocalStorage support check now skips the enterWith() capability probe on Bun. Other runtimes retain the existing probe. Tests cover the Bun behavior and restore stubbed globals after each test.

Changes

Bun AsyncLocalStorage fix

Layer / File(s) Summary
Bun-specific capability guard
packages/evlog/src/shared/asyncStorageScope.ts
Bun returns true without calling enterWith(). Other runtimes retain the existing validation and probe.
Regression test and release note
packages/evlog/test/shared/asyncStorageScope.test.ts, .changeset/safe-context-probe.md
Tests verify that Bun does not invoke enterWith() and clean up stubbed globals. The changeset documents the patch.
Estimated code review effort: 2 (Simple) ~10 minutes

Possibly related PRs

Suggested reviewers: hugorcd

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Elysia fix and the avoided AsyncLocalStorage probe on Bun.
Description check ✅ Passed The description explains the Bun issue, fallback behavior, regression test, and linked issue.
Linked Issues check ✅ Passed The changes prevent the Bun probe while preserving fallback and request-time behavior required by issue #496.
Out of Scope Changes check ✅ Passed The changes are limited to the Bun detection fix, regression coverage, and its changeset.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@pkg-pr-new

pkg-pr-new Bot commented Aug 3, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@evlog/cli@497
npm i https://pkg.pr.new/evlog@497
npm i https://pkg.pr.new/@evlog/nuxthub@497
npm i https://pkg.pr.new/@evlog/telemetry@497

commit: 9d9df53

@adrian-scehura
adrian-scehura marked this pull request as ready for review August 3, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Elysia AsyncLocalStorage probe breaks bun:test lifecycle hooks

1 participant