isaacs / node-lru-cache

A fast cache that automatically deletes the least recently used items
http://isaacs.github.io/node-lru-cache/
ISC License
5.39k stars 353 forks source link

Windows 11 - npm test - error #260

Closed pacostas closed 2 years ago

pacostas commented 2 years ago

System Details:

Edition: Windows 11 pro N
Version: 22H2
OS build 22621.525
Experience Windows Feature Experience Pack 1000.22634.1000.0
Processor: 12th Gen Inter(R) Core(TM) i7-1255U 2.61 GHZ
RAM: 10GB
System type: 64-bit operating system, x64-based processor

The OS runs on Virtual machine on KVM

Error 1:

 ✖ 1 native context

      )
      t.equal(
--------^
        profile.number_of_native_contexts,
        1,

  --- expected
  +++ actual
  @@ -1,1 +1,1 @@
  -1
  +2

  test: test/avoid-memory-leak.ts both max and maxSize
  at:
    line: 72
    column: 9
    file: test/avoid-memory-leak.ts
  stack: |
    test/avoid-memory-leak.ts:72:9
    test/avoid-memory-leak.ts:10:71
    new Promise (<anonymous>)
    __awaiter (test/avoid-memory-leak.ts:6:12)
    runTest (test/avoid-memory-leak.ts:51:66)
    Test.<anonymous> (test/avoid-memory-leak.ts:116:3)
    Object.<anonymous> (test/avoid-memory-leak.ts:115:3)
    Module.replacementCompile (node_modules/append-transform/index.js:60:13)
    Module.m._compile (node_modules/ts-node/src/index.ts:1455:23)
    module.exports (node_modules/default-require-extensions/js.js:7:9)
    node_modules/append-transform/index.js:64:4
    require.extensions.<computed> (node_modules/ts-node/src/index.ts:1458:12)
    Object.<anonymous> (node_modules/append-transform/index.js:64:4)

​ FAIL ​ test/avoid-memory-leak.ts

How to reproduce it

npm i 
npm test

Node versions this error appears:

16 and above

isaacs commented 2 years ago

This is very strange, since CI on this module runs on Windows 11 and Node 16, and passes reliably since fixing #227. Did anything change in Node recently that might be related to this?

isaacs commented 2 years ago

Aha! Found a bug in my CI workflow, it actually wasn't running tests in that env.

Debugging now, thanks for finding this, yay canaries!

isaacs commented 2 years ago

Ok, as far as I can tell, number_of_native_contexts is just going to be 2 sometimes instead of 1 on Windows. There are no native contexts being created by this module, and it doesn't appear to be growing unbounded. The heap size is staying relatively constant, which was the original problem addressed by #227. I'm going to adjust the test to be less strict.

isaacs commented 2 years ago

Fixed by 5729f5254d5c816f6a38baa917fdb6387819e5c6

pacostas commented 1 year ago

@isaacs Thank you for your fast response! I'm still investigating why this is not running on citgm https://github.com/nodejs/citgm/pull/934 despite it runs on windows 11 with all node.js versions.

isaacs commented 1 year ago

It's failing in the citgm code for some reason:

    # Subtest: grab-project: teardown
        not ok 1 - EBUSY: resource busy or locked, rmdir 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\citgm-1670840855810'
          ---
          errno: -4082
          code: EBUSY
          syscall: rmdir
          path: C:\Users\RUNNER~1\AppData\Local\Temp\citgm-1670840855810
          tapCaught: returnedPromiseRejection
          test: "grab-project: teardown"
          ...

        1..1
        # failed 1 test
    not ok 10 - grab-project: teardown # time=655.543ms

    1..10
    # failed 1 of 10 tests
    # time=11673.994ms
not ok 17 - test/test-grab-project.js # time=11673.994ms
  ---
  env: {}
  file: test/test-grab-project.js
  timeout: 480000
  command: C:\hostedtoolcache\windows\node\19.2.0\x64\node.exe
  args:
    - test/test-grab-project.js
  stdio:
    - 0
    - pipe
    - 2
  cwd: D:\a\citgm\citgm
  exitCode: 1
  ...

I don't know what "test-grab-project.js" does, but it looks like it's a citgm thing, not an lru-cache thing.