nx 23.2.1 fails with SqliteFailure Some("FOREIGN KEY constraint failed") after every target completes
Current Behavior
After upgrading from nx 23.1.0 to 23.2.1 I get this error after running every target:
NX Successfully ran target build for project util
Nx read the output from the cache instead of running the command for 1 out of 1 tasks.
Run duration: 103ms
Cache: 1/1 hit (100%)
Critical path: 46ms (1 task)
Recoverable time: <1ms
NX DB transaction error: SqliteFailure(Error { code: ConstraintViolation, extended_code: 787 }, Some("FOREIGN KEY constraint failed"))
Error: DB transaction error: SqliteFailure(Error { code: ConstraintViolation, extended_code: 787 }, Some("FOREIGN KEY constraint failed"))
at TaskHistory.recordTaskRuns (c:\src\ftl\webui-nx\node_modules\nx\dist\src\\\utils\task-history.js:32:37)
at handleRecordTaskRuns (c:\src\ftl\webui-nx\node_modules\nx\dist\src\daemon\server\handle-task-history.js:9:23)
at c:\src\ftl\webui-nx\node_modules\nx\dist\src\daemon\server\server.js:195:122
at handleResult (c:\src\ftl\webui-nx\node_modules\nx\dist\src\daemon\server\server.js:238:20)
at handleMessage (c:\src\ftl\webui-nx\node_modules\nx\dist\src\daemon\server\server.js:195:15)
at c:\src\ftl\webui-nx\node_modules\nx\dist\src\daemon\server\server.js:82:15
at Socket.<anonymous> (c:\src\ftl\webui-nx\node_modules\nx\dist\src\\\utils\consume-messages-from-socket.js:226:13)
at Socket.emit (node:events:509:28)
at addChunk (node:internal/streams/readable:563:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:514:3)I'm not receiving this error on the github ubuntu build agent, only receiving it on Windows dev workstations.
Expected Behavior
No errors when running tasks.
GitHub Repo
No response
Steps to Reproduce
I wasn't able to reproduce on the https://github.com/nrwl/nx-examples repo - I did test out changing the dependency versions from 23.3.0-beta.0 to 23.2.1 . I don't have time now to set up a new repo and try to figure out why it's occurring.
Nx Report
yarn nx report
NX Report complete - copy this into the issue template
Node : 24.16.0
OS : win32-x64
Native Target : x86_64-windows
yarn : 4.18.0
daemon : Available
nx : 23.2.1
@nx/js : 23.2.1
@nx/eslint : 23.2.1
@nx/workspace : 23.2.1
@nx/angular : 23.2.1
@nx/devkit : 23.2.1
@nx/eslint-plugin : 23.2.1
@nx/vite : 23.2.1
@nx/vitest : 23.2.1
@nx/web : 23.2.1
typescript : 6.0.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/eslint/plugin
---------------------------------------
Community plugins:
@ngneat/spectator : 22.1.0
@testing-library/angular : 19.4.1
angular-eslint : 22.5.0
ng-mocks : 14.15.3
---------------------------------------
Cache
- Usage: 1.19 MB / 95.10 GB (0.0%)
- Location: ~\.nx\8004eb097f4dfc0d\cacheFailure Logs
Package Manager Version
No response
Operating System
- macOS
- Linux
- Windows
- Other (Please specify)
Additional Information
This occurs even on simple targets like command targets with a simple command line. It appears to be a db corruption issue - were there any constraints that were changed between these two versions?
It does occur reliably by upgrading to version 23.2.1. If I switch back to 23.1.0 and delete the .nx directory it goes away, then comes back by switching back to version 23.2.1.
Source: nrwl/nx