Berry: [Bug] Hapi Swagger fails when using PnP

Created on 2 Jan 2021  路  3Comments  路  Source: yarnpkg/berry

  • [ x ] I'd be willing to implement a fix

Describe the bug

Please find a repro project here.
It contains:

It works OK with Yarn Classic but crashes when installed with Yarn Berry.

The repo contains:

  • a minimal package.json + working code for repro,
  • everything for yarn: lock, rc, .yarn/releases
  • gitignore, editorconfig, and other IDE related stuff.

To Reproduce

  1. Clone the repo,
  2. yarn install
  3. When the console says hapi on http://localhost:3000, open the URL of the endpoint documentation: http://localhost:3000/documentation

Expected Behavior

Swagger UI to be displayed with no error in the console.

Actual Result

No UI in the browser,
The following error in the console:

Click for a lot of console output...

(node:20128) UnhandledPromiseRejectionWarning: RangeError [ERR_OUT_OF_RANGE]: The value of "fd" is out of range. It must be >= 0 && <= 2147483647. Received -2147483645
    at Object.fstat (fs.js:964:3)
    at internal/util.js:297:30
    at new Promise (<anonymous>)
    at Object.fstat (internal/util.js:296:12)
    at exports.File.stat (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\fs.js:63:40)
    at exports.File.openStat (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\fs.js:82:21)
    at async Object.internals.prepare (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\file.js:107:22)
    at async exports.Manager.execute (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-hapi-npm-20.0.3-d3b5a60d99-7d9a68f8b2.zip\node_modules\@hapi\hapi\lib\toolkit.js:105:28)
    at async Object.internals.handler (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-hapi-npm-20.0.3-d3b5a60d99-7d9a68f8b2.zip\node_modules\@hapi\hapi\lib\handler.js:46:20)
    at async exports.execute (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-hapi-npm-20.0.3-d3b5a60d99-7d9a68f8b2.zip\node_modules\@hapi\hapi\lib\handler.js:31:20)
(node:20128) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function 
without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)       
(node:20128) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:20128) UnhandledPromiseRejectionWarning: RangeError [ERR_OUT_OF_RANGE]: The value of "fd" is out of range. It must be >= 0 && <= 2147483647. Received -2147483644
    at Object.fstat (fs.js:964:3)
    at internal/util.js:297:30
    at new Promise (<anonymous>)
    at Object.fstat (internal/util.js:296:12)
    at exports.File.stat (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\fs.js:63:40)
    at exports.File.openStat (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\fs.js:82:21)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Object.internals.prepare (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\file.js:107:22)
    at async exports.Manager.execute (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-hapi-npm-20.0.3-d3b5a60d99-7d9a68f8b2.zip\node_modules\@hapi\hapi\lib\toolkit.js:105:28)
    at async Object.internals.handler (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-hapi-npm-20.0.3-d3b5a60d99-7d9a68f8b2.zip\node_modules\@hapi\hapi\lib\handler.js:46:20)
(node:20128) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function 
without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)       
(node:20128) UnhandledPromiseRejectionWarning: RangeError [ERR_OUT_OF_RANGE]: The value of "fd" is out of range. It must be >= 0 && <= 2147483647. Received -2147483643
    at Object.fstat (fs.js:964:3)
    at internal/util.js:297:30
    at new Promise (<anonymous>)
    at Object.fstat (internal/util.js:296:12)
    at exports.File.stat (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\fs.js:63:40)
    at exports.File.openStat (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\fs.js:82:21)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Object.internals.prepare (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\file.js:107:22)
    at async exports.Manager.execute (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-hapi-npm-20.0.3-d3b5a60d99-7d9a68f8b2.zip\node_modules\@hapi\hapi\lib\toolkit.js:105:28)
    at async Object.internals.handler (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-hapi-npm-20.0.3-d3b5a60d99-7d9a68f8b2.zip\node_modules\@hapi\hapi\lib\handler.js:46:20)
(node:20128) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function 
without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 9)       
(node:20128) UnhandledPromiseRejectionWarning: RangeError [ERR_OUT_OF_RANGE]: The value of "fd" is out of range. It must be >= 0 && <= 2147483647. Received -2147483642
    at Object.fstat (fs.js:964:3)
    at internal/util.js:297:30
    at new Promise (<anonymous>)
    at Object.fstat (internal/util.js:296:12)
    at exports.File.stat (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\fs.js:63:40)
    at exports.File.openStat (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\fs.js:82:21)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Object.internals.prepare (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-inert-npm-6.0.3-4c290df46a-82a4a790c8.zip\node_modules\@hapi\inert\lib\file.js:107:22)
    at async exports.Manager.execute (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-hapi-npm-20.0.3-d3b5a60d99-7d9a68f8b2.zip\node_modules\@hapi\hapi\lib\toolkit.js:105:28)
    at async Object.internals.handler (D:\Projects\tests\hapi-swagger\.yarn\cache\@hapi-hapi-npm-20.0.3-d3b5a60d99-7d9a68f8b2.zip\node_modules\@hapi\hapi\lib\handler.js:46:20)
(node:20128) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function 
without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 12)      

Environment if relevant (please complete the following information):

  • OS: WIndows 10
  • Node version v12.19.0
  • Yarn version 2.4.0

Additional context

The failing line is the following:

    const stat = await exports.fstat(this.fd);

Please give me a clue on where to start unpuzzling such issues related to yarn. It does not seem to be related to any wrong dependencies as usual. Thanks.

bug upholded

All 3 comments

Implemented support for fstat in https://github.com/yarnpkg/berry/pull/2320, you can try it by using

yarn set version from sources --branch 2320

@merceyz , the fstat fix did the trick, the working project is here Thanks!

Any implications with the failed tests?

Any implications with the failed tests?

No, it's because of a issue with an invalid semver version upstream

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mike-Dax picture Mike-Dax  路  3Comments

thealjey picture thealjey  路  4Comments

bradleyayers picture bradleyayers  路  3Comments

dzintars picture dzintars  路  3Comments

chrisands picture chrisands  路  3Comments