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

The "fd" argument must be of type number. Received null - Erroring in recent Node versions 20 and 21 #50979

Closed
SamTV12345 opened this issue Nov 30, 2023 · 4 comments · Fixed by #50994

Comments

@SamTV12345
Copy link

SamTV12345 commented Nov 30, 2023

Version

v21.2.0

Platform

Linux/MacOS/Windows - same error on all three platforms

Subsystem

No response

What steps will reproduce the bug?

  1. git clone [email protected]:ether/ueberDB.git && git checkout fix/tests
  2. Install Node: Node 20.3.0 works, the respective versions 20 and 21 were released in a time window of 5 days ago
  3. npm i
  4. Run the file test/lib/test.spec.ts
  5. See the tests failing on recent Node versions

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

It should run without a problem.

What do you see instead?

TypeError: The "fd" argument must be of type number. Received null

Additional information

No response

@marco-ippolito
Copy link
Member

marco-ippolito commented Nov 30, 2023

Can you share a minimal reproducible example without 3rd party libraries and a stacktrace?

@SamTV12345
Copy link
Author

Sure I'll create one in the next few hours. It was thrown in the dirty db implementation so it shouldn't be too hard to track that down.

@SamTV12345
Copy link
Author

SamTV12345 commented Nov 30, 2023

@marco-ippolito Here is the example. I just put it into a test so I can easily start it from webstorm

import {describe, it} from "vitest";
import {TMP_PATH} from "./config";
import fs, {createWriteStream} from "fs";

describe('test-node-failure',  () =>{

    it('should allow .on load to chain to constructor', async function () {
        let path = "test.txt"
        let _writeStream = createWriteStream(path, {
            encoding: 'utf-8',
            flags: 'a',
        });
            let _queue = new Map();
            let key = 'key';

            const cbs = _queue.get(key) || [];
            _queue.set(key, cbs);
        _writeStream.cork();
        for (const [key, _] of _queue) {
            _queue.delete(key);
            const data = `${JSON.stringify({key, val: "test"})}\n`;
            _writeStream.write(data, (err) => {
                console.log(err)
            });
        }
        _writeStream.uncork();
        });
});

@SamTV12345
Copy link
Author

SamTV12345 commented Nov 30, 2023

Stacktrace looks like this:

TypeError: The "fd" argument must be of type number. Received null
    at Object.write (node:fs:834:8)
    at WriteStream.writeAll (node:internal/fs/streams:418:13)
    at WriteStream._write (node:internal/fs/streams:477:12)
    at doWrite (node:internal/streams/writable:590:12)
    at clearBuffer (node:internal/streams/writable:773:7)
    at WriteStream.Writable.uncork (node:internal/streams/writable:523:7)
    at C:\Users\user\WebstormProjects\dirty_db\test\test-minimal.test.ts:25:22
    at file:///C:/Users/user/WebstormProjects/dirty_db/node_modules/@vitest/runner/dist/index.js:135:14
    at file:///C:/Users/user/WebstormProjects/dirty_db/node_modules/@vitest/runner/dist/index.js:58:26
    at runTest (file:///C:/Users/user/WebstormProjects/dirty_db/node_modules/@vitest/runner/dist/index.js:663:17)

nodejs-github-bot pushed a commit that referenced this issue Dec 7, 2023
PR-URL: #50994
Fixes: #50979
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Raz Luvaton <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
RafaelGSS pushed a commit that referenced this issue Dec 15, 2023
PR-URL: #50994
Fixes: #50979
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Raz Luvaton <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
richardlau pushed a commit that referenced this issue Mar 25, 2024
PR-URL: #50994
Fixes: #50979
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Raz Luvaton <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
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.

2 participants