Closed spock123 closed 2 weeks ago
I can confirm that error; let me check. Maybe I can come with a PR
Quick update: The error comes when more than just one file is migrated. Expect fix PR soon.
Thanks @rainerhahnekamp
In my case the migration fails with this error:
Migration failed: Index 500 outside of range [0, 388].
@pfeileon, can you please post the content of the file where that happened (as long as you are allowed to do that)? The PR is still open, so I can add a fix to it, if you have a case, we didn't think of.
@pfeileon, can you please post the content of the file where that happened (as long as you are allowed to do that)? The PR is still open, so I can add a fix to it, if you have a case, we didn't think of.
Sorry, I don't know which file causes this issue, it just happens after several lines of
[@ngrx/effects] Updated concatLatestFrom to import from '@ngrx/operators'
but no file is actually changed.
angular-errors.log:
[error] Error: Index 500 outside of range [0, 388]. at UpdateRecorderBase._assertIndex (/home/pfeileon/git/my-app/node_modules/@angular-devkit/schematics/src/tree/recorder.js:65:19) at UpdateRecorderBase.remove (/home/pfeileon/git/my-app/node_modules/@angular-devkit/schematics/src/tree/recorder.js:80:14) at createChangeRecorder (/home/pfeileon/git/my-app/node_modules/@ngrx/effects/schematics-core/utility/change.js:138:26) at commitChanges (/home/pfeileon/git/my-app/node_modules/@ngrx/effects/schematics-core/utility/change.js:157:20) at /home/pfeileon/git/my-app/node_modules/@ngrx/effects/migrations/18_0_0-beta/index.js:89:49 at visitTSSourceFiles (/home/pfeileon/git/my-app/node_modules/@ngrx/effects/schematics-core/utility/visitors.js:66:22) at /home/pfeileon/git/my-app/node_modules/@ngrx/effects/migrations/18_0_0-beta/index.js:37:50 at callRuleAsync (/home/pfeileon/git/my-app/node_modules/@angular-devkit/schematics/src/rules/call.js:77:24) at /home/pfeileon/git/my-app/node_modules/@angular-devkit/schematics/src/rules/call.js:72:40 at Observable._subscribe (/home/pfeileon/git/my-app/node_modules/rxjs/dist/cjs/internal/observable/defer.js:8:31)
Btw, the update to v18 also causes issues with linting:
An unhandled exception occurred: Failed to load config "plugin:@ngrx/recommended-requiring-type-checking" to extend from.
But I guess that's a separate issue and might have to do with @angular-eslint/schematics and @typescript-eslint/utils (as there is a peer dependency issue).
@pfeileon, that error message comes from a file that is importing concatLatestFrom
from @ngrx/effects
. I don't know how large your application is, but if it is just a bunch of files importing that operator, you could send them to me via email as well. I can figure out if there is a bug.
My email address is straightforward: rainer.hahnekamp[at]gmail.com
I guessed as much ;-) but I'm not sure if that's helpful because all of the imports of concatLatestFrom
have already correctly referenced @ngrx/operators
before the update.
I checked the files and in all of them (5 in all, but the message in the console is printed 29 times) the import looks like this:
import { concatLatestFrom } from '@ngrx/operators';
The lines before and after are syntactically correct as well (only imports some with an empty line after).
The component tests are actually working and the app can be served locally so the issue doesn't seem to be harmful. I'm not sure if it's worth the trouble (I'd need to change the file contents first, check if the same error happens, etc.)...
I see. I think that the PR covers your error as well. In your case, you probably had a change somewhere and the migration script tried to apply those changes to all files with an import @ngrx/effects
.
I see. I think that the PR covers your error as well. In your case, you probably had a change somewhere and the migration script tried to apply those changes to all files with an import
@ngrx/effects
.
The git status was clean if that's what you mean. But after a quick look, the code changes in the linked PR do have some additional checks which might prevent this issue.
Hi @rainerhahnekamp,
I’m working on migrating from v17 to v18 and have encountered a blocking issue due to the issue mentioned by @pfeileon. Index 1829 outside of range [0, 1153]
NX Running migrations from 'migrations.json'
<!-- Multiple occurences of below statement --> [@ngrx/effects] Updated concatLatestFrom to import from '@ngrx/operators'
NX Failed to run ngrx-effects-migration-18-beta from @ngrx/effects. This workspace is NOT up to date!
NX Index 1829 outside of range [0, 1153].
Error: Index 1829 outside of range [0, 1153]. at UpdateRecorderBase._assertIndex (C:\Work\CS-Source\scui\node_modules\@angular-devkit\schematics\src\tree\recorder.js:65:19) at UpdateRecorderBase.remove (C:\Work\CS-Source\scui\node_modules\@angular-devkit\schematics\src\tree\recorder.js:80:14) at createChangeRecorder (C:\Work\CS-Source\scui\node_modules\@ngrx\effects\schematics-core\utility\change.js:138:26) at commitChanges (C:\Work\CS-Source\scui\node_modules\@ngrx\effects\schematics-core\utility\change.js:157:20) at C:\Work\CS-Source\scui\node_modules\@ngrx\effects\migrations\18_0_0-beta\index.js:89:49 at visitTSSourceFiles (C:\Work\CS-Source\scui\node_modules\@ngrx\effects\schematics-core\utility\visitors.js:66:22) at C:\Work\CS-Source\scui\node_modules\@ngrx\effects\migrations\18_0_0-beta\index.js:37:50 at callRuleAsync (C:\Work\CS-Source\scui\node_modules\@angular-devkit\schematics\src\rules\call.js:77:24) at C:\Work\CS-Source\scui\node_modules\@angular-devkit\schematics\src\rules\call.js:72:40 at Observable._subscribe (C:\Work\CS-Source\scui\node_modules\rxjs\dist\cjs\internal\observable\defer.js:8:31) error Command failed with exit code 1.
Could you please let me know when the fix for this will be published?
@brandonroberts I guess that's your call then 😉
Thanks @rainerhahnekamp 🙂. 18.0.1
has been released with the migration fixes
Thanks, @brandonroberts and @rainerhahnekamp. The patch works fine.
Which @ngrx/* package(s) are the source of the bug?
schematics
Minimal reproduction of the bug/regression with instructions
We are trying to upgrade a larger application. The application is running Angular 18, NGRX 17.2 After performing a seemingly successful upgrade with
ng update @ngrx/store
, all imports in all files have errors and double entries.Example:
A file using NGRX contains these imports (notice there is an import using path alias in the middle)
Now we run the migration:
After migration, the file now contains the following.
This happens to hundreds of files that contain NGRX imports.
Expected behavior
Migration should not mess up imports /s
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)
Ngrx: 17.2.0 Angular: 18.0.3 OS: MacOS Sonoma 14.2
Other information
No response
I would be willing to submit a PR to fix this issue