fix(@stdlib/string/base/atob): guard global atob reference to prevent ReferenceError#13329
Draft
Planeshifter wants to merge 2 commits into
Draft
fix(@stdlib/string/base/atob): guard global atob reference to prevent ReferenceError#13329Planeshifter wants to merge 2 commits into
atob reference to prevent ReferenceError#13329Planeshifter wants to merge 2 commits into
Conversation
…nt ReferenceError The `linux_test` workflow's Node.js v12/v14 jobs failed on every scheduled run on develop with `ReferenceError: atob is not defined` at `lib/global.js:23`. Root cause: the file re-exported the bare `atob` identifier directly; on Node runtimes that predate the global `atob`/`btoa` (added in Node 16+), referencing an undeclared identifier without `typeof` throws at module-evaluation time, so merely requiring `main.js` (which requires `global.js` at its top level) crashed before any test ran. This commit guards the reference with `typeof atob === 'function'`, mirroring the identical, already-correct idiom used by the sibling `@stdlib/assert/has-atob-support` package, so requiring the module now yields `null` instead of throwing on environments lacking a global `atob`. Ref: https://github.com/stdlib-js/stdlib/actions/runs/28785480753
…guarded `atob` reference The `lint_changed_files` CI check on PR #13329 flagged the guarded `typeof atob === 'function'` reference with `n/no-unsupported-features/node-builtins`, since the package's `engines` range (`>=0.12.18`) predates the stable global `atob`. This is the same intentional, guarded pattern already used for other version-gated globals (e.g. `@stdlib/bigint/ctor`, `@stdlib/proxy/ctor`), which disable the corresponding rule on the same line. Do the same here. Ref: https://github.com/stdlib-js/stdlib/actions/runs/28798431195
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
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.
Description
This pull request:
lib/node_modules/@stdlib/string/base/atob/lib/global.js, which re-exported the bare globalatobidentifier directly. On Node.js runtimes that predate the globalatob/btoa(added in Node 16+), referencing an undeclared identifier without atypeofguard throwsReferenceError: atob is not definedat module-evaluation time. Becausemain.jsrequiresglobal.jsat its top level, outside any try/catch, merely requiring the package crashed on Node 12/14. This broke thelinux_testCI workflow's Node.js v12 and v14 jobs on every scheduled run againstdevelop. The fix guards the reference withtypeof atob === 'function', matching the identical pattern already used by the sibling@stdlib/assert/has-atob-supportpackage.Related Issues
None.
Questions
No.
Other
Found and fixed as part of automated CI-failure triage. Failing run: https://github.com/stdlib-js/stdlib/actions/runs/28785480753 (job:
linux_test, Node.js v14; also reproduced on Node.js v12 and the macOS Node.js v16 job of the same run).Validated by reproducing the crash and fix locally via a Node script that deletes
globalThis.atoband confirmsrequire()no longer throws. Reviewed by three independent passes (correctness, regression scope, style/conventions); all approved with no blocking findings.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code as part of an automated CI-failure triage and fix routine, based on live GitHub Actions job log analysis. The fix was reviewed by three independent automated review passes before being proposed here.
@stdlib-js/reviewers
Generated by Claude Code