Skip to content

fix(scripts): scanGlob — захист від Bun.Glob#scan(), що повертає Promise на self-hosted Linux Bun 1.3.14 - #203

Merged
vitaliytv merged 3 commits into
mainfrom
claude/changelog-consistency-bun-linux-2b8b98
Jul 24, 2026
Merged

fix(scripts): scanGlob — захист від Bun.Glob#scan(), що повертає Promise на self-hosted Linux Bun 1.3.14#203
vitaliytv merged 3 commits into
mainfrom
claude/changelog-consistency-bun-linux-2b8b98

Conversation

@vitaliytv

Copy link
Copy Markdown
Member

Summary

  • changelog/consistency (always-active, scope: full) threw an unhandled exception on every per-service CI pipeline running on self-hosted Linux Bun 1.3.14: detector changelog/consistency: lint() кинув: yield* ... is not async iterable. Not reproducible locally on macOS ARM.
  • Root cause: Bun.Glob#scan() on that Linux Bun build returns Promise<AsyncIterable> instead of an async-iterable directly (as it does on macOS). yield* on a bare Promise throws, since Promise has neither Symbol.asyncIterator nor Symbol.iterator.
  • Fix, scoped to the single call site (npm/scripts/utils/glob-compat.mjs): added resolveGlobScan(), which awaits the scan result only if it's thenable, then passes it to scanGlob's yield*. scanGlob also gained an optional { bun } injection point so both return shapes are directly unit-testable without mutating globalThis (repo lint forbids that).
  • Added unit tests covering both Bun.Glob#scan() shapes plus the existing Node fallback (node:fs/promises#glob) and hasIgnoredPathSegment.
  • Regenerated the file doc and added a changefile (patch/Fixed) per repo convention.

Test plan

  • npx vitest run npm/scripts/utils/tests/glob-compat.test.mjs — 8/8 passing, covers both Bun.Glob#scan() return shapes and the Node fallback
  • npx @7n/rules lint — exit 0, 0 violations across all 23 concerns
  • Verify on the actual self-hosted Linux Bun 1.3.14 CI runner that bun x n-rules lint --path <module> --no-fix no longer throws (could not reproduce locally on macOS ARM, per the original report)

🤖 Generated with Claude Code

vitaliytv and others added 3 commits July 24, 2026 17:07
…ise на self-hosted Linux Bun 1.3.14

На self-hosted Linux Bun 1.3.14 `Bun.Glob#scan()` повертає Promise<AsyncIterable>
замість async-iterable напряму (як на macOS) — `yield*` на Promise падає з
"is not async iterable", бо в Promise немає ні Symbol.asyncIterator, ні
Symbol.iterator. Через це changelog/consistency (scope: full, завжди активний)
валив увесь lint --path/--full прогін у per-service CI-пайплайнах.

Додано resolveGlobScan(), що розрізняє обидві форми повернення, і опційна
ін'єкція { bun } у scanGlob для прямого юніт-тестування обох гілок без
мутації globalThis.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…istency-bun-linux-2b8b98

# Conflicts:
#	.cspell.json
@vitaliytv
vitaliytv merged commit 7dc07d6 into main Jul 24, 2026
5 of 7 checks passed
vitaliytv added a commit that referenced this pull request Jul 27, 2026
…up (#260)

Investigation of #203 showed the changelog/consistency crash
("yield* … is not async iterable") correlates with whether the external
n-rules script is invoked via `bun x` vs directly, not with OS/Bun version
as originally assumed — the Bun.Glob#scan() Promise hypothesis is disproven
by 16/16 clean direct calls on the same self-hosted Linux agent.

The one concretely fixable half of that report: js/eslint spawned `bunx` by
literal name, relying on inherited $PATH — this ENOENTs on self-hosted CI
when n-rules is invoked directly (bypassing bun x). Both call sites now
resolve bunx via resolveCmd (absolute path), matching the pattern already
used everywhere else in this codebase for cargo/uv/shellcheck/etc.

Also documents the bun x + patchedDependencies interaction observed during
this investigation (bun x does not apply patchedDependencies for local
devDependencies) so it doesn't trip up future diagnostics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant