nx: Cannot run @angular/material v15 migrations: Expected a synchronous delegate but got an asynchronous one
Current Behavior
I am in the middle of upgrading from Angular + Material v14 to v15. When running the @angular/material migrations, I get the following error
$ nx migrate --runMigrations --verbose
> NX Running 'npm install' to make sure necessary packages are installed
[...]
> NX Failed to run migration-v15 from @angular/material. This workspace is NOT up to date!
> NX Expected a synchronous delegate but got an asynchronous one.
Error: Expected a synchronous delegate but got an asynchronous one.
at SyncDelegateHost._doSyncCall (C:\Users\kro\WebstormProjects\nx-migration-bug-reproduction\node_modules\@angular-devkit\core\src\virtual-fs\host\sync.js:39:19)
at SyncDelegateHost.read (C:\Users\kro\WebstormProjects\nx-migration-bug-reproduction\node_modules\@angular-devkit\core\src\virtual-fs\host\sync.js:57:21)
at LazyFileEntry._load (C:\Users\kro\WebstormProjects\nx-migration-bug-reproduction\node_modules\@angular-devkit\schematics\src\tree\host-tree.js:252:80)
at LazyFileEntry.get content [as content] (C:\Users\kro\WebstormProjects\nx-migration-bug-reproduction\node_modules\@angular-devkit\schematics\src\tree\entry.js:34:55)
at HostTree.read (C:\Users\kro\WebstormProjects\nx-migration-bug-reproduction\node_modules\@angular-devkit\schematics\src\tree\host-tree.js:211:30)
at getWorkspaceConfigGracefully (C:\Users\kro\WebstormProjects\nx-migration-bug-reproduction\node_modules\@angular\cdk\schematics\utils\project-tsconfig-paths.js:24:31)
at C:\Users\kro\WebstormProjects\nx-migration-bug-reproduction\node_modules\@angular\cdk\schematics\ng-update\devkit-migration-rule.js:51:91
at callRuleAsync (C:\Users\kro\WebstormProjects\nx-migration-bug-reproduction\node_modules\@angular-devkit\schematics\src\rules\call.js:78:24)
at C:\Users\kro\WebstormProjects\nx-migration-bug-reproduction\node_modules\@angular-devkit\schematics\src\rules\call.js:73:40
at Observable._subscribe (C:\Users\kro\WebstormProjects\nx-migration-bug-reproduction\node_modules\@angular-devkit\schematics\node_modules\rxjs\internal\observable\defer.js:10:21)
I migrated to Nx during Angular 14 and thought I might have missed something. Therefore, I did npx nx@latest migrate --from=nx@14 and it actually found a couple of missing migrations. On top of that, I tried nx repair but without any significant changes - the error still exists.
I had the same issue with some of the Angular 15 migrations (not all) but ignored them because these migrations were irrelevant for me.
Expected Behavior
Run migrations for @angular/material successfully.
GitHub Repo
https://github.com/kroeder/nx-15_7-migration-bug-reproduction
Steps to Reproduce
- Clone https://github.com/kroeder/nx-15_7-migration-bug-reproduction
npm installnx migrate --run-migrations
The output should be
$ nx migrate --run-migrations
> NX Running 'npm install' to make sure necessary packages are installed
up to date, audited 1427 packages in 2s
found 0 vulnerabilities
> NX Running migrations from 'migrations.json'
> NX Failed to run migration-v15 from @angular/material. This workspace is NOT up to date!
> NX Expected a synchronous delegate but got an asynchronous one.
Pass --verbose to see the stacktrace.
Nx Report
Node : 16.18.0
OS : win32 x64
npm : 8.19.2
nx : 15.7.0
@nrwl/jest : 15.7.0
@nrwl/linter : 15.7.0
@nrwl/workspace : 15.7.0
@nrwl/angular : 15.7.0
@nrwl/cli : 15.7.0
@nrwl/cypress : 15.7.0
@nrwl/devkit : 15.7.0
@nrwl/eslint-plugin-nx : 15.7.0
@nrwl/js : 15.7.0
@nrwl/tao : 15.7.0
@nrwl/webpack : 15.7.0
@nrwl/nx-cloud : 15.0.3
typescript : 4.8.4
Failure Logs
No response
Additional Information
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 5
- Comments: 29 (6 by maintainers)
Hey all! Thanks for reporting this!
I’m sorry you’re facing this issue. We are fully aware of it and we are troubleshooting it. We’ll have a fix for it as soon as possible.
This issue seems worthy of a patch release on its own. Please don’t take this as a complaint. I’m very happy that it was fixed so quickly! I’m just anxious to get the fix into my hands. 😃
I need to quote this again
Within 24 hours there was a response to this issue, only a few days to merge a fix and all we now need to do is to have a little bit of patience until it gets released 🙏
Thanks for fixing this so fast! 🙂
I’m experiencing this too. Same behavior for
nx migrate latest(for 15.7.0) andnx migrate 15.6.3.Thank you for quick response. Do you have a timeframe when patch will be released? We are in the middle of migration and need to make a decision today/tomorrow if roll it back or continue forward.
2 scripts fail: { “version”: “14.0.0-0”, “description”: “Updates the Angular CDK to v14”, “factory”: “./ng-update/index#updateToV14”, “package”: “@angular/cdk”, “name”: “migration-v14” }, { “version”: “14.0.0-0”, “description”: “Updates the Angular Material to v14”, “factory”: “./ng-update/index#updateToV14”, “package”: “@angular/material”, “name”: “migration-v14” }
Would that be possible to update code manually for failed scripts?
After upgrade getting error when generating library, can you please help and let me know reason why it can be happening?
PS C:\Users\dimitri.liberman\nx14upgrade\tps-client> nx g @nrwl/angular:library my-ui-lib --tags=ui --dry-run > NX Generating @nrwl/angular:library [NX] Angular devkit called
writeWorkspace, this may have had unintended consequences in angular.json [NX] Double check angular.json before proceeding Skipping my-ui-lib since libs\my-ui-lib\project.json already exists. UPDATE angular.json CREATE libs/my-ui-lib/README.md CREATE libs/my-ui-lib/tsconfig.lib.json CREATE libs/my-ui-lib/tsconfig.spec.json CREATE libs/my-ui-lib/src/index.ts CREATE libs/my-ui-lib/src/lib/my-ui-lib.module.ts CREATE libs/my-ui-lib/tsconfig.json CREATE libs/my-ui-lib/project.json UPDATE tsconfig.base.json CREATE libs/my-ui-lib/jest.config.ts CREATE libs/my-ui-lib/src/test-setup.ts CREATE libs/my-ui-lib/.eslintrc.jsonhey all! The fix has been merged and it will be released in a patch version. Once released, the issue would be solved for all versions of Nx. The
migratecommand always installs thelatestversion of Nx to collect and run migrations, that’s why the issue happened to multiple versions.Keep an eye on the releases to get the fix!
+1 And I cannot even update with using
ngcommand.First I had to do in PowerShell v7.3.2
$Env:FORCE_NG_UPDATE = "true";Then I get response
Using Nx to run Angular CLI commands is deprecated and will be removed in a future version. To run Angular CLI commands, use \ng`. Error: This command is not available when running the Angular CLI outside a workspace. `Maybe it’s somehow related, maybe it’s not. Adding just for sake of more info
The latest push from @leosvelperez resolved this issue.
npm i nx@15.8.5 --forcenx generate @angular/material:mdc-migrationhey @IBot18!
The error is the same, but it’s triggered by a different command which is run differently. Please open a new issue with a repro and tag me. I’ll take it from there.
Omg I’m really getting tired of this
Same here. When to expect the 15.8.0 release?
Hi, thank you for taking quick actions.
I don’t know if it’s already present in 15.8.0-beta.1, but when I tried to test to migrate to this version I got the same error
> NX Failed to run migration-v15 from @angular/cdk. This workspace is NOT up to date!> NX Expected a synchronous delegate but got an asynchronous one.