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

Stalls with Yarn and Node 10 #497

Closed
nickserv opened this issue Apr 26, 2018 · 24 comments
Closed

Stalls with Yarn and Node 10 #497

nickserv opened this issue Apr 26, 2018 · 24 comments

Comments

@nickserv
Copy link

nickserv commented Apr 26, 2018

Issue

I have a project using ts-jest and Yarn, and my test suite now stalls completely with the first test in progress on Node 10. This is not an issue when using Jest with Node 9, npm, or without ts-jest.

Expected behavior

Tests pass, as they do on Node 9 or npm.

Link to a minimal repo that reproduces this issue

  • Install ts-jest with Yarn
  • Install Node 10
  • Run Jest

Workarounds

  • Run npm install, you can still use Yarn to run your test script
  • Use Node 9 or older
@kulshekhar
Copy link
Owner

@nickmccurdy I understand that this could probably be replicated using any setup but creating that setup takes some time. So I'd greatly appreciate if you could add a minimal repo for this - something I can git clone and test on. I'll be taking a look at some issues in ts-jest this weekend so if there's a minimal repo for this, it's a lot more likely to be addressed. Thanks!

@nickserv
Copy link
Author

nickserv commented Apr 27, 2018

Yea sorry, I was being a bit lazy filing this issue, but now I can't even replicate this bug in my original project. 😓 It seems to work fine for some reason, I'll try to send a reproduction if I encounter it again.

@kulshekhar
Copy link
Owner

@nickmccurdy sure, no problem. I'll close this issue for now. If you run into it again and think it's related to ts-jest, this issue can be re-opened

@nickserv
Copy link
Author

@evertbouw @mudcrab Do you have any public examples of this issue or something you can share?

@evertbouw
Copy link

I may be able to create something tomorrow

@evertbouw
Copy link

evertbouw commented Apr 27, 2018

Created it https://github.com/evertbouw/ts-jest-node-10

When you run Jest here it will stall on the test that should fail. Fix the test and it works

@kulshekhar can you reopen? thanks

@nickserv
Copy link
Author

@evertbouw Sweet thanks! This has a similar setup to something I tried that passed, I'll see if I can figure out what part of the tsconfig causes it

@kulshekhar kulshekhar reopened this Apr 27, 2018
@nickserv
Copy link
Author

nickserv commented Apr 27, 2018

It's Yarn, not the config. I just realized I only see the issue in @evertbouw's repo when installing with Yarn. Installing with Yarn and testing with npm stalls, while installing with npm and testing with Yarn passes. This also happens if I recreate the lock file. Works fine on Node 9.

@nickserv nickserv changed the title Jest stalls in Node 10 Stalls with Yarn and Node 10 Apr 27, 2018
@kulshekhar
Copy link
Owner

@nickmccurdy does this issue persist even if plain jest is used with js? (trying to figure out whether it's a ts-jest specific issue)

I don't have node 10 installed so I'm asking you

@kulshekhar
Copy link
Owner

kulshekhar commented Apr 27, 2018

maybe one of our dependencies has a hard-coded engine requirement That doesn't sound right

@nickserv
Copy link
Author

nickserv commented Apr 27, 2018

The same configuration works if ts-jest is removed and the ts extension is changed to js. So it's a combination of ts-jest, Node 10, and Yarn (for installation, not task running).

@kulshekhar
Copy link
Owner

kulshekhar commented Apr 27, 2018

This looks like it might be a pure yarn issue: yarnpkg/yarn#5727

Does yarn install --ignore-engines work?

@nickserv
Copy link
Author

The description is vague, but I think it's a different issue. The upath module doesn't support Node 10 which unfortunately breaks very popular packages like Webpack because Yarn fails installs on invalid peer dependencies by default. However, upath is not in this package's yarn.lock, and the installation succeeds, it just causes an install that leads to stalling tests.

@kulshekhar
Copy link
Owner

hmmm. ok, I'll leave this open and actually test this out tomorrow in a fresh VM instead of posting various hypotheses :)

@nickserv
Copy link
Author

No worries. 😄 It's a tricky one

@evertbouw
Copy link

Can confirm, works fine if I use npm i but not yarn. --ignore-engines does not make a difference, this would have cancelled the yarn install otherwise.

@kulshekhar
Copy link
Owner

kulshekhar commented Apr 28, 2018

I've just tested this in a fresh VM. The install works. The test stalls (yarn test and npm run test).

root@localhost:~# node -v
v10.0.0
root@localhost:~# yarn -v
1.6.0
root@localhost:~# git --version
git version 2.7.4

root@localhost:~# git clone https://github.com/evertbouw/ts-jest-node-10
Cloning into 'ts-jest-node-10'...
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 8 (delta 0), reused 8 (delta 0), pack-reused 0
Unpacking objects: 100% (8/8), done.
Checking connectivity... done.

root@localhost:~# cd ts-jest-node-10/
root@localhost:~/ts-jest-node-10# ls
package.json  src  tsconfig.json  yarn.lock

root@localhost:~/ts-jest-node-10# yarn
yarn install v1.6.0
(node:6210) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 12.94s.

root@localhost:~/ts-jest-node-10# ls
node_modules  package.json  src  tsconfig.json  yarn.lock

root@localhost:~/ts-jest-node-10# yarn test
yarn run v1.6.0
(node:6231) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
$ jest

 RUNS  src/myfile.test.ts
^C

root@localhost:~/ts-jest-node-10#
root@localhost:~/ts-jest-node-10# npm run test

> [email protected] test /root/ts-jest-node-10
> jest


 RUNS  src/myfile.test.ts
^C

root@localhost:~/ts-jest-node-10#

@kulshekhar
Copy link
Owner

Installing with npm install and running the test (npm run test and yarn test) works

root@localhost:~/ts-jest-node-10# rm node_modules/ yarn.lock  -rf
root@localhost:~/ts-jest-node-10# ls
package.json  src  tsconfig.json
root@localhost:~/ts-jest-node-10# npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 615 packages in 19.901s
root@localhost:~/ts-jest-node-10# npm run test

> [email protected] test /root/ts-jest-node-10
> jest

 FAIL  src/myfile.test.ts
  the world
    ✕ should still exist (13ms)

  ● the world › should still exist

    expect(received).toBe(expected) // Object.is equality
    
    Expected value to be:
      3
    Received:
      2

      1 | describe("the world", () => {
      2 |     it("should still exist", () => {
    > 3 |         expect(1 + 1).toBe(3);
      4 |     });
      5 | });
      
      at Object.<anonymous> (src/myfile.test.ts:3:23)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        1.867s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `jest`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-04-28T22_10_20_472Z-debug.log
root@localhost:~/ts-jest-node-10# yarn test
yarn run v1.6.0
(node:6463) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
$ jest
 FAIL  src/myfile.test.ts
  the world
    ✕ should still exist (11ms)

  ● the world › should still exist

    expect(received).toBe(expected) // Object.is equality
    
    Expected value to be:
      3
    Received:
      2

      1 | describe("the world", () => {
      2 |     it("should still exist", () => {
    > 3 |         expect(1 + 1).toBe(3);
      4 |     });
      5 | });
      
      at Object.<anonymous> (src/myfile.test.ts:3:23)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        1.875s, estimated 2s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
root@localhost:~/ts-jest-node-10# 

@kulshekhar
Copy link
Owner

I'm not sure what's going on but given that this works after an npm install and not after a yarn install means there's a problem with yarn + node 10.

In this case, this problem occurs with ts-jest but I'm not sure what in ts-jest is triggering this issue. Regardless of what's triggering it, it's unlikely that the fix for this lies in ts-jest.

I'm going to keep this open so that if there's a workaround that we can implement in ts-jest to get around this, we'll do that. But I don't think a permanent fix for this issue lies here.

@nickserv
Copy link
Author

nickserv commented Apr 28, 2018

Hm, maybe we could open a debugger in Jest's runner to see what stack frames it's stuck on when it's stalling. It would probably be an issue with the installation of a specific package in Yarn and Node 10.

@kulshekhar
Copy link
Owner

I was tempted to do that but ... time issues 🙁 (especially since I'm reasonably confident the fix doesn't lie in ts-jest)

If I thought the fix was in ts-jest, I'd happily give this more time.

@jethrolarson
Copy link

jethrolarson commented Apr 30, 2018

I experienced this as well.
OSX Sierra 10.12.6
node 10.0.0
jest 22.4.3
ts-jest 2.4.4
typescript 2.8.3

Running on Node 9 resolved the issue.

@williamoliveira
Copy link

Could be related? nodejs/node#20258

@nickserv
Copy link
Author

nickserv commented May 9, 2018

Node 10.1 is out and appears to fix this.

@nickserv nickserv closed this as completed May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants