An error (UNHANDLED REJECTION Lock is already released) is thrown when closing a development session on MacOS using Ctrl+C (SIGINT) after upgrading to Gatsby 2.24.53.
The error is only thrown when running development using npm run develop. It does not occur if using a globally installed instance of the CLI using gatsby develop
The issue occurs only on MacOS - I could not replicate under Windows 10 on WSL2.
gatsby new gatsby-2.24.53-test (the same occurs if just using npx gatsby new...). At this stage Gatsby is installed at v2.24.50. The error does not occur under this build.npm run develop and then (once built) hit Ctrl+C to confirm the development build shuts down cleanly.npm outdated and you'll see 2.24.53 is the version that will be installed on an update.npm update to get the latest version. gatsby develop (so using the global installation of the CLI). Hitting Ctrl+C exits cleanly.npm run develop instead.Ctrl+C to end developmentsuccess Building development bundle - 4.092s
^C
ERROR
UNHANDLED REJECTION Lock is already released
Error: Lock is already released
- lockfile.js:257
[gatsby-2.24.53-test]/[proper-lockfile]/lib/lockfile.js:257:60
- adapter.js:39
[gatsby-2.24.53-test]/[proper-lockfile]/lib/adapter.js:39:9
- new Promise
- adapter.js:30 unlock
[gatsby-2.24.53-test]/[proper-lockfile]/lib/adapter.js:30:25
- develop.ts:465 forEach
[gatsby-2.24.53-test]/[gatsby]/src/commands/develop.ts:465:19
- Array.forEach
- develop.ts:464 shutdownServices
[gatsby-2.24.53-test]/[gatsby]/src/commands/develop.ts:464:11
- develop.ts:411 process.<anonymous>
[gatsby-2.24.53-test]/[gatsby]/src/commands/develop.ts:411:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] develop: `gatsby develop`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] develop script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
The error occurred regardless of terminal used (iTerm2 or Terminal).
The error did not occur under 2.24.52 or below.
I wanted to ensure it wasn't an issue with my local CLI configuration so I formatted a spare MacBook Pro. I re-installed MacOS Catalina and then installed only Xcode CLI tools (for git) and nvm using the curl install option. Once nvm was installed I ran nvm install node following by npm install -g gatsby and restarted Terminal. I then followed the steps outlined above and had the same result on a fresh cleanly installed version of MacOS.
I expect the development build to shut down cleanly without error when running npm run develop.
An error UNHANDLED REJECTION Lock is already released is thrown instead.
It appears that SIGINT is called twice on MacOS. This does not occur under Windows 10 using WSL2
System:
OS: macOS 10.15.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Shell: 5.8 - /usr/local/bin/zsh
Binaries:
Node: 14.9.0 - ~/.nvm/versions/node/v14.9.0/bin/node
npm: 6.14.8 - ~/.nvm/versions/node/v14.9.0/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 85.0.4183.83
Edge: 85.0.564.44
Firefox: 79.0
Safari: 13.1.2
npmPackages:
gatsby: ^2.24.53 => 2.24.53
gatsby-image: ^2.4.16 => 2.4.16
gatsby-plugin-manifest: ^2.4.27 => 2.4.27
gatsby-plugin-offline: ^3.2.26 => 3.2.26
gatsby-plugin-react-helmet: ^3.3.10 => 3.3.10
gatsby-plugin-sharp: ^2.6.31 => 2.6.31
gatsby-source-filesystem: ^2.3.27 => 2.3.27
gatsby-transformer-sharp: ^2.5.14 => 2.5.14
npmGlobalPackages:
gatsby-cli: 2.12.91
I'm not sure why the SIGINT handler gets called twice on MacOS.
But the second time the shutdownServices function is run it's for the same developProcess which now has isRunning set to false. The thing is, shutdownServices doesn't take that into account and tries to rerun the unlocks block on items that have already been unlocked.
I'm still curious _why_ it gets triggered twice though 馃
I used yarn to install packages and got this problem when run npm run develop. Then, I switched to yarn run develop, the bug has gone. Not sure it could help but just my case 馃槃
I could reproduce this on mac with npm install and npm run develop. Not with yarn. Looking for a fix
Most helpful comment
Successfully published:
Let me know if it got fixed :)