Skip to content

SchematicTestRunner.runExternalSchematic fails with "The encoded data was not valid for encoding utf-8" #27643

Closed
@daniel-sc

Description

@daniel-sc

Command

other

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

17.0.0

Description

With v18.0.0-rc.1 under some conditions (which exactly is unclear to me) SchematicTestRunner.runExternalSchematic fails with the following error: "The encoded data was not valid for encoding utf-8"

See e.g. https://github.com/daniel-sc/ng-extract-i18n-merge/actions/runs/9091527710/job/24986317152?pr=111

The exact same test runs fine with angular 17: https://github.com/daniel-sc/ng-extract-i18n-merge/actions/runs/9091527710/job/24986316954?pr=111

This is the line were it fails: https://github.com/daniel-sc/ng-extract-i18n-merge/blob/master/schematics/ng-add/index.spec.ts#L45 (unsure why the first invocation succeeds..)

Minimal Reproduction

  1. Checkout branch angular-18 from https://github.com/daniel-sc/ng-extract-i18n-merge
  2. remove package-lock.json
  3. run npm i --save-exact "@angular-devkit/architect@0.1800.0-rc.1" "@angular-devkit/core@18.0.0-rc.1" "@angular-devkit/schematics@18.0.0-rc.1" "@schematics/angular@18.0.0-rc.1" "@angular-devkit/build-angular@18.0.0-rc.1" "@angular/core@18.0.0-rc.1" "@angular/compiler-cli@18.0.0-rc.1"
  4. run npm run build
  5. run npm run test-coverage

Exception or Error

The encoded data was not valid for encoding utf-8
TypeError: The encoded data was not valid for encoding utf-8
    at TextDecoder.decode (node:internal/encoding:449:16)
    at C:\projekte\ng-extract-i18n-merge\node_modules\@angular-devkit\schematics\src\rules\template.js:38:44
    at C:\projekte\ng-extract-i18n-merge\node_modules\@angular-devkit\schematics\src\rules\base.js:135:23
    at C:\projekte\ng-extract-i18n-merge\node_modules\@angular-devkit\schematics\src\rules\base.js:89:20
    at C:\projekte\ng-extract-i18n-merge\node_modules\@angular-devkit\schematics\src\rules\base.js:113:30
    at C:\projekte\ng-extract-i18n-merge\node_modules\@angular-devkit\schematics\src\tree\host-tree.js:278:13
    at C:\projekte\ng-extract-i18n-merge\node_modules\@angular-devkit\schematics\src\tree\host-tree.js:51:61
    at Array.forEach (<anonymous>)
    at HostDirEntry.visit (C:\projekte\ng-extract-i18n-merge\node_modules\@angular-devkit\schematics\src\tree\host-tree.js:51:43)
    at HostCreateTree.visit (C:\projekte\ng-extract-i18n-merge\node_modules\@angular-devkit\schematics\src\tree\host-tree.js:277:19)
    at C:\projekte\ng-extract-i18n-merge\node_modules\@angular-devkit\schematics\src\rules\base.js:109:14
    at callRuleAsync (C:\projekte\ng-extract-i18n-merge\node_modules\@angular-devkit\schematics\src\rules\call.js:77:24)
    at C:\projekte\ng-extract-i18n-merge\node_modules\@angular-devkit\schematics\src\rules\call.js:69:63
    at doInnerSub (C:\projekte\ng-extract-i18n-merge\node_modules\rxjs\src\internal\operators\mergeInternals.ts:71:15)
    at outerNext (C:\projekte\ng-extract-i18n-merge\node_modules\rxjs\src\internal\operators\mergeInternals.ts:53:58)
    at OperatorSubscriber._this._next (C:\projekte\ng-extract-i18n-merge\node_modules\rxjs\src\internal\operators\OperatorSubscriber.ts:70:13)
    at OperatorSubscriber.Object.<anonymous>.Subscriber.next (C:\projekte\ng-extract-i18n-merge\node_modules\rxjs\src\internal\Subscriber.ts:75:12)
    at C:\projekte\ng-extract-i18n-merge\node_modules\rxjs\src\internal\operators\mergeInternals.ts:85:24
    at OperatorSubscriber._this._next (C:\projekte\ng-extract-i18n-merge\node_modules\rxjs\src\internal\operators\OperatorSubscriber.ts:70:13)
    at OperatorSubscriber.Object.<anonymous>.Subscriber.next (C:\projekte\ng-extract-i18n-merge\node_modules\rxjs\src\internal\Subscriber.ts:75:12)
    at C:\projekte\ng-extract-i18n-merge\node_modules\rxjs\src\internal\observable\innerFrom.ts:90:24

Your Environment

Angular CLI: 17.3.3
Node: 20.12.0
Package Manager: npm 10.5.0
OS: win32 x64

Angular: 18.0.0-rc.1
... compiler-cli, core

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1800.0-rc.1
@angular-devkit/core         18.0.0-rc.1
@angular-devkit/schematics   18.0.0-rc.1
@schematics/angular          18.0.0-rc.1
typescript                   5.4.5

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions