-
-
Notifications
You must be signed in to change notification settings - Fork 191
Closed
Description
resolve.sync of a module with a package.json containing main: '.' will hang for quite some time, (up to 800ms on my machine) and then return return the correct value...
Steps to reproduce:
mkdir -p node_modules/evil/
echo '{"main": "."}' > node_modules/evil/package.json
touch node_modules/evil/index.jsrequire('resolve').sync('evil') // => "path/to/node_modules/evil/index.js" (but very slow)If the try/catch is removed from https://github.com/substack/node-resolve/blob/master/lib/sync.js#L73 you instead get a fun stack overflow
> require('.').sync('evil')
RangeError: Maximum call stack size exceeded
at new fs.Stats (fs.js:133:20)
at Object.fs.statSync (fs.js:907:18)
at isFile (/Users/spenner/src/substack/node-resolve/lib/sync.js:14:27)
at loadAsFileSync (/Users/spenner/src/substack/node-resolve/lib/sync.js:45:13)
at loadAsDirectorySync (/Users/spenner/src/substack/node-resolve/lib/sync.js:68:29)
at loadAsDirectorySync (/Users/spenner/src/substack/node-resolve/lib/sync.js:70:29)
at loadAsDirectorySync (/Users/spenner/src/substack/node-resolve/lib/sync.js:70:29)
at loadAsDirectorySync (/Users/spenner/src/substack/node-resolve/lib/sync.js:70:29)
at loadAsDirectorySync (/Users/spenner/src/substack/node-resolve/lib/sync.js:70:29)
at loadAsDirectorySync (/Users/spenner/src/substack/node-resolve/lib/sync.js:70:29)
Metadata
Metadata
Assignees
Labels
No labels