Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.6.0: [ERR_INVALID_ARG_TYPE] when using preprocess #47

Closed
Jak-Ch-ll opened this issue May 26, 2021 · 9 comments · Fixed by #49
Closed

v1.6.0: [ERR_INVALID_ARG_TYPE] when using preprocess #47

Jak-Ch-ll opened this issue May 26, 2021 · 9 comments · Fixed by #49

Comments

@Jak-Ch-ll
Copy link

Jak-Ch-ll commented May 26, 2021

Hi there,

I was just setting up a new project with TS and have gotten a complex error on starting the test (see below). After fiddling a bit, I tried Version 1.5.0 didn't have the issue. Since I could reproduce the issue on 2 machines, I'm quite sure, the cause lies in v1.6.0 of svelte-jester.

These were my steps:

  • update node form version 14.13.0 to version 14.17.0 (LTS) > same error code from the title, but different "details"
  • test on another machine (node v14.15.4) > same error as first machine before update
  • downgrade of svelte-jester to version 1.5.0 > no error, tests work fine on both machines

I created a repo with which the error should be reproducible: https://github.com/Jak-Ch-ll/svelte-jester-error


Error on first machine (Windows 10, node v14.17.0, svelte-jster v1.6.0)

internal/process/promises.js:213
        triggerUncaughtException(err, true /* fromPromise */);
        ^

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received 
an instance of NodeError
    at Socket.Writable.write (internal/streams/writable.js:285:13)
    at file:///D:/data/learning/udemy/svelte-tdd/node_modules/svelte-jester/src/preprocess.js:11:32 {
  code: 'ERR_INVALID_ARG_TYPE'
}
 FAIL  src/pages/SignUpPage.spec.ts
  ● Test suite failed to run

    Command failed: node --unhandled-rejections=strict --abort-on-uncaught-exception D:\data\learning\udemy\svelte-tdd\node_modules\svelte-jester\src\preprocess.js
    internal/process/promises.js:213
            triggerUncaughtException(err, true /* fromPromise */);
            ^

    TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of NodeError
        at Socket.Writable.write (internal/streams/writable.js:285:13)
        at file:///D:/data/learning/udemy/svelte-tdd/node_modules/svelte-jester/src/preprocess.js:11:32 {
      code: 'ERR_INVALID_ARG_TYPE'
    }


      at Socket.Writable.write (internal/streams/writable.js:285:13)
      at file:/D:/data/learning/udemy/svelte-tdd/node_modules/svelte-jester/src/preprocess.js:11:32 {
        code: 'ERR_INVALID_ARG_TYPE'
      }
      at Object.process (node_modules/svelte-jester/src/transformer.cjs:17:28)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:612:31)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:758:40)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:815:19)

Error on second machine (Windows 10, node v14.15.4, svelte-jster v1.6.0)

internal/process/promises.js:213
        triggerUncaughtException(err, true /* fromPromise */);
        ^

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of NodeError
    at Socket.Writable.write (internal/streams/writable.js:285:13)
    at file:///C:/Users/J.c/Documents/learning/svelte-tdd/node_modules/svelte-jester/src/preprocess.js:11:32 {
  code: 'ERR_INVALID_ARG_TYPE'
}
 1: 00007FF7BCC8058F napi_wrap+109311
 2: 00007FF7BCC252B6 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfElementsOffset+33302
 3: 00007FF7BCC27BB9 node::OnFatalError+7257
 4: 00007FF7BD49E72F v8::internal::Builtins::builtin_handle+321471
 5: 00007FF7BD49DCC4 v8::internal::Builtins::builtin_handle+318804
 6: 00007FF7BD49DFB7 v8::internal::Builtins::builtin_handle+319559
 7: 00007FF7BD49DE03 v8::internal::Builtins::builtin_handle+319123
 8: 00007FF7BD579F9D v8::internal::SetupIsolateDelegate::SetupHeap+464173
 9: 00007FF7BD5128A2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
10: 00007FF7BD5128A2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
11: 00007FF7BD51055E v8::internal::SetupIsolateDelegate::SetupHeap+31470
12: 00007FF7BD51014C v8::internal::SetupIsolateDelegate::SetupHeap+30428
13: 00007FF7BD3E0631 v8::internal::Execution::CallWasm+1649
14: 00007FF7BD3DFE9F v8::internal::Execution::Call+191
15: 00007FF7BD4CB7E7 v8::Function::Call+615
16: 00007FF7BCCA42DD node::CallbackScope::~CallbackScope+861
17: 00007FF7BCCA3FEE node::CallbackScope::~CallbackScope+110
18: 00007FF7BCC0EA38 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfBucketsOffset+199704
19: 00007FF7BCCD8017 uv_timer_stop+775
20: 00007FF7BCCD484B uv_async_send+331
21: 00007FF7BCCD3FDC uv_loop_init+1292
22: 00007FF7BCCD417A uv_run+202
23: 00007FF7BCBE02B5 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfBucketsOffset+9365
24: 00007FF7BCC53A17 node::Start+311
25: 00007FF7BCAB686C RC4_options+339820
26: 00007FF7BDA5604C v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+153532
27: 00007FFE42997034 BaseThreadInitThunk+20
28: 00007FFE447E2651 RtlUserThreadStart+33
 FAIL  src/pages/SignUpPage.spec.ts
  ● Test suite failed to run

    Command failed: node --unhandled-rejections=strict --abort-on-uncaught-exception C:\Users\J.c\Documents\learning\svelte-tdd\node_modules\svelte-jester\src\preprocess.js
    internal/process/promises.js:213
            triggerUncaughtException(err, true /* fromPromise */);
            ^

    TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of NodeError
        at Socket.Writable.write (internal/streams/writable.js:285:13)
        at file:///C:/Users/J.c/Documents/learning/svelte-tdd/node_modules/svelte-jester/src/preprocess.js:11:32 {
      code: 'ERR_INVALID_ARG_TYPE'
    }
     1: 00007FF7BCC8058F napi_wrap+109311
     2: 00007FF7BCC252B6 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfElementsOffset+33302
     3: 00007FF7BCC27BB9 node::OnFatalError+7257
     4: 00007FF7BD49E72F v8::internal::Builtins::builtin_handle+321471
     5: 00007FF7BD49DCC4 v8::internal::Builtins::builtin_handle+318804
     6: 00007FF7BD49DFB7 v8::internal::Builtins::builtin_handle+319559
     7: 00007FF7BD49DE03 v8::internal::Builtins::builtin_handle+319123
     8: 00007FF7BD579F9D v8::internal::SetupIsolateDelegate::SetupHeap+464173
     9: 00007FF7BD5128A2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
    10: 00007FF7BD5128A2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
    11: 00007FF7BD51055E v8::internal::SetupIsolateDelegate::SetupHeap+31470
    12: 00007FF7BD51014C v8::internal::SetupIsolateDelegate::SetupHeap+30428
    13: 00007FF7BD3E0631 v8::internal::Execution::CallWasm+1649
    14: 00007FF7BD3DFE9F v8::internal::Execution::Call+191
    15: 00007FF7BD4CB7E7 v8::Function::Call+615
    16: 00007FF7BCCA42DD node::CallbackScope::~CallbackScope+861
    17: 00007FF7BCCA3FEE node::CallbackScope::~CallbackScope+110
    18: 00007FF7BCC0EA38 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfBucketsOffset+199704
    19: 00007FF7BCCD8017 uv_timer_stop+775
    20: 00007FF7BCCD484B uv_async_send+331
    21: 00007FF7BCCD3FDC uv_loop_init+1292
    22: 00007FF7BCCD417A uv_run+202
    23: 00007FF7BCBE02B5 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfBucketsOffset+9365
    24: 00007FF7BCC53A17 node::Start+311
    25: 00007FF7BCAB686C RC4_options+339820
    26: 00007FF7BDA5604C v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+153532
    27: 00007FFE42997034 BaseThreadInitThunk+20
    28: 00007FFE447E2651 RtlUserThreadStart+33


      at Socket.Writable.write (internal/streams/writable.js:285:13)
      at file:/C:/Users/J.c/Documents/learning/svelte-tdd/node_modules/svelte-jester/src/preprocess.js:11:32 {
        code: 'ERR_INVALID_ARG_TYPE'
      }
       1: 00007FF7BCC8058F napi_wrap+109311
       2: 00007FF7BCC252B6 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfElementsOffset+33302
       3: 00007FF7BCC27BB9 node::OnFatalError+7257
       4: 00007FF7BD49E72F v8::internal::Builtins::builtin_handle+321471
       5: 00007FF7BD49DCC4 v8::internal::Builtins::builtin_handle+318804
       6: 00007FF7BD49DFB7 v8::internal::Builtins::builtin_handle+319559
       7: 00007FF7BD49DE03 v8::internal::Builtins::builtin_handle+319123
      8: 00007FF7BD579F9D v8::internal::SetupIsolateDelegate::SetupHeap+464173
      9: 00007FF7BD5128A2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
      10: 00007FF7BD5128A2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
      11: 00007FF7BD51055E v8::internal::SetupIsolateDelegate::SetupHeap+31470
      12: 00007FF7BD51014C v8::internal::SetupIsolateDelegate::SetupHeap+30428
      13: 00007FF7BD3E0631 v8::internal::Execution::CallWasm+1649
      14: 00007FF7BD3DFE9F v8::internal::Execution::Call+191
      15: 00007FF7BD4CB7E7 v8::Function::Call+615
      16: 00007FF7BCCA42DD node::CallbackScope::~CallbackScope+861
      17: 00007FF7BCCA3FEE node::CallbackScope::~CallbackScope+110
      18: 00007FF7BCC0EA38 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfBucketsOffset+199704
      19: 00007FF7BCCD8017 uv_timer_stop+775
      20: 00007FF7BCCD484B uv_async_send+331
      21: 00007FF7BCCD3FDC uv_loop_init+1292
      22: 00007FF7BCCD417A uv_run+202
      23: 00007FF7BCBE02B5 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfBucketsOffset+9365
      24: 00007FF7BCC53A17 node::Start+311
      25: 00007FF7BCAB686C RC4_options+339820
      26: 00007FF7BDA5604C v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+153532
      27: 00007FFE42997034 BaseThreadInitThunk+20
      28: 00007FFE447E2651 RtlUserThreadStart+33
      at Object.process (node_modules/svelte-jester/src/transformer.cjs:17:28)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:612:31)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:758:40)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:815:19)
@sebastianrothe
Copy link
Collaborator

sebastianrothe commented May 26, 2021

Is there another error message at the top? Like

> jest --watch "--no-watch" "--ci" "--no-cache"

(node:30785) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/process/promises:227
        triggerUncaughtException(err, true /* fromPromise */);
        ^

@sebastianrothe
Copy link
Collaborator

Could you downgrade jest and ts-jest to 26.* ? It seems we are not compatible to v27 yet.

@sebastianrothe
Copy link
Collaborator

With Jest v27 I can't get it to work. Even if I downgrade svelte-jester to 1.5.0

I get this:

({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export default function slash(path) {
                                                                                      ^^^^^^

    SyntaxError: Unexpected token 'export'

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1479:14)

@Jak-Ch-ll
Copy link
Author

Jak-Ch-ll commented May 27, 2021

Regarding your questions:

  1. No there is no more error above what I copied, only the command I used, which was jest --watch
  2. It's the same error for me with Jest v26.6.3 and ts-jest 26.5.4.
  3. I did download my git and tested with that and it still works. Not sure why you are getting a completely different error

@sebastianrothe
Copy link
Collaborator

sebastianrothe commented May 31, 2021

Regarding your questions:

1. No there is no more error above what I copied, only the command I used, which was `jest --watch`

2. It's the same error for me with Jest v26.6.3 and ts-jest 26.5.4.

3. I did download my git and tested with that and it still works. Not sure why you are getting a completely different error

That's because I did run it on OSX. I used another machine with windows and fixed the error. Should be released soon.

@agorer
Copy link

agorer commented Jun 9, 2021

Hello,
I have the same error running on OSX with Jest v26.6.3, ts-jest 26.5.6 and svelte-jester 1.7.0. Is the fix already released?

@sebastianrothe
Copy link
Collaborator

Hello,
I have the same error running on OSX with Jest v26.6.3, ts-jest 26.5.6 and svelte-jester 1.7.0. Is the fix already released?

Yes, it should be fixed. Can you provide a repo, where we can test your code?

@agorer
Copy link

agorer commented Jun 9, 2021

Can you provide a repo, where we can test your code?

Sure,
I have isolated the problem here: https://www.dropbox.com/s/5dt8wd92bzj7ftl/test-project.zip?dl=0 (after npm install you can run the tests with npm run test:unit).

Don't know if it changes anything, but my node version is 16.3.0.

@sebastianrothe
Copy link
Collaborator

sebastianrothe commented Jun 9, 2021

Can you provide a repo, where we can test your code?

Sure,
I have isolated the problem here: https://www.dropbox.com/s/5dt8wd92bzj7ftl/test-project.zip?dl=0 (after npm install you can run the tests with npm run test:unit).

Don't know if it changes anything, but my node version is 16.3.0.

Thanks. Got it! The real error is swallowed. Node complains about mixing commonJS and ESM. You can fix it, if you rename your svelte.test.config.js to svelte.test.config.mjs. You need to adjust the path to the file in jest.config.js too.

I will fix the lib to not swallow the error.

OR

You could declare your project as type: "module", then all .js files are treated as ESM, but you need to rename your commonJS files to .cjs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants