fix(@stdlib/string/base/atob): guard against ReferenceError when atob global is absent - #14592
Draft
Planeshifter wants to merge 2 commits into
Draft
fix(@stdlib/string/base/atob): guard against ReferenceError when atob global is absent#14592Planeshifter wants to merge 2 commits into
ReferenceError when atob global is absent#14592Planeshifter wants to merge 2 commits into
Conversation
…tob` global is absent The job `Node.js v12` and `Node.js v14` of workflow `linux_test` failed on develop with `ReferenceError: atob is not defined`. Root cause: `lib/global.js` unconditionally referenced the bare global identifier `atob`, which Node.js only defines starting in v16, so merely requiring the module threw at evaluation time on older versions. This module is required eagerly by `lib/main.js`, itself required eagerly by the package's test files, crashing the test suite before the existing `hasAtobSupport()` skip logic ever ran. This commit guards the reference with `typeof atob === 'function'`, matching the existing pattern in `@stdlib/assert/has-atob-support`, so requiring the module no longer throws on environments lacking a native `atob` global. Ref: https://github.com/stdlib-js/stdlib/actions/runs/32710852762
… error CI's `Lint Changed Files` check failed on the prior commit: `n/no-unsupported-features/node-builtins` flags any reference to the `atob` identifier as unsupported given this package's `engines.node` range (`>=0.10.0`), including inside `typeof atob`. The established repo convention for this exact situation is an inline `eslint-disable-line n/no-unsupported-features/node-builtins` comment (see `@stdlib/process/geteuid/lib/native.js`); this commit adds it. Ref: https://github.com/stdlib-js/stdlib/actions/runs/32738069504
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:module.exports = atob;referenced the bareatobglobal unconditionally. Node.js only definesatobglobally starting in v16; on Node.js 12/14, evaluating the undeclared identifier threw aReferenceErrorat module load, not at call time. Sincelib/main.jsrequires this module eagerly, and the package's test files requirelib/main.jsat top level, the crash happened before the existinghasAtobSupport()-gatedtapeskip logic could run, breaking thelinux_testworkflow's Node.js v12 and v14 jobs on every scheduled run (https://github.com/stdlib-js/stdlib/actions/runs/32710852762). Fix: guard the reference withvar main = ( typeof atob === 'function' ) ? atob : null;, matching the existing idiom in@stdlib/assert/has-atob-support/lib/atob.js.require('@stdlib/string/base/atob')in production is unaffected — that path resolves throughlib/index.jsviahasAtobSupport()and never hits this file's bug.Related Issues
This pull request has the following related issues:
Questions
No.
Other
Diff: one file, 6 lines added, 1 removed.
No
node_modulesinstall was possible in this environment, so verification used Node'svmmodule to evaluate the file in a fresh V8 context: no throw and correctnullfallback withatobabsent from globals, correct pass-through withatobpresent.Reviewed independently across correctness, regression scope, and style/conventions before opening. All three passes flagged the same non-blocking issue from an early draft: an
// eslint-disable-line stdlib/no-redeclarecomment was unnecessary — that rule only fires on declarations shadowing a global of the same name, andvar maindoesn't shadowatob— and would have tripped--report-unused-disable-directives. Removed before commit.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was investigated, written, and validated by Claude Code as part of an automated CI-failure triage routine: it identified the failing
linux_testjobs, traced the root cause, implemented the fix, and validated it via three independent automated review passes (correctness, regression scope, style/conventions) before opening this PR.@stdlib-js/reviewers
Generated by Claude Code