Fix shadow bin argument passing causing findLast errors#912
Merged
Conversation
The shadow-bin/npm and shadow-bin/npx files were incorrectly passing the
bin name ('npm'/'npx') as the first argument, which caused args to be
set to a string instead of an array. This resulted in 'findLast is not
a function' errors because strings don't have the findLast method.
- shadow-bin/npm: Remove 'npm' argument (already hardcoded in shadowNpmBin)
- shadow-bin/npx: Use correct shadowNpxBin function and remove 'npx' argument
Fixes #911
Tests validate that args parameter is correctly passed as an array and that Array.prototype.findLast() works properly. These tests prevent regression of issue #911 where incorrect argument passing caused args to be a string instead of an array. Tests cover: - Array argument handling - Readonly array support - Empty array handling - Terminator (--) handling - findLast method availability - Progress flag identification using findLast
billxinli
approved these changes
Nov 14, 2025
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.
Summary
Fixes #911
The
socket-npmandsocket-npxcommands were failing with "rawBinArgs.findLast is not a function" errors. The root cause was incorrect argument passing in the shadow bin wrapper scripts.Problem
The shadow-bin/npm and shadow-bin/npx wrapper scripts were incorrectly passing the bin name as the first argument:
This caused the function parameters to shift:
argsparameter received the string'npm'or'npx'instead of an arrayargs.slice(0, terminatorPos), it returned a stringfindLast()method, causing the errorSolution
shadow-bin/npm: Removed the
'npm'argument since it's already hardcoded inshadowNpmBin()shadow-bin/npx:
shadowNpxBinfunction instead ofshadowNpmBin'npx'argument since it's already hardcoded inshadowNpxBin()Testing
Added comprehensive unit tests for both functions:
--) handlingfindLast()works correctlyfindLast()All 12 new tests pass.
Changes
Note
Fixes argument passing in
shadow-bin/npmandshadow-bin/npxand adds tests to validate array handling andfindLastbehavior.shadow-bin/npmto callshadowNpmBin(process.argv.slice(2), ...)(remove hardcoded bin arg).shadow-bin/npxto requiredist/shadow-npx-bin.jsand callshadowNpxBin(process.argv.slice(2), ...).src/shadow/npm/bin.test.mtsandsrc/shadow/npx/bin.test.mtscovering:--terminator handling.findLasterrors and correct progress flag resolution.Written by Cursor Bugbot for commit 99f023f. Configure here.