Skip to content

stdlib doesn't throw Node arg-validation errors (ERR_INVALID_ARG_TYPE/EBADF/...) on bad input — ~85 tests across fs/buffer/net/http/crypto/zlib/process #2013

@proggeramlug

Description

@proggeramlug

Summary

Cross-cutting parity theme, surfaced when assert.throws got fixed (#1924): Perry's APIs don't throw Node's argument-validation errors on invalid input. ~85 tests across nearly every API now correctly fail with "Missing expected exception" (the call didn't throw) or wrong error code.

Confirmed repro (perry 0.5.1032):

import * as fs from "node:fs";
fs.readFileSync(123 as any);   // Perry: returns/no throw   Node: throws EBADF
fs.accessSync(true as any);    // Perry: throws code=undefined   Node: ERR_INVALID_ARG_TYPE

Breadth (assert.throws-style failures that were false-passing before #1924)

API failures API failures
fs 40 crypto 7
buffer 10 process 8
net 10 url 2
zlib 10 timers 1
http 9

What to do

Implement Node's input validation + error codes (ERR_INVALID_ARG_TYPE, ERR_OUT_OF_RANGE, EBADF, ...) on the stdlib surface — at minimum throw with the right .code/.name on bad arg types/values. This is the single highest-leverage parity theme now: it spans 7+ APIs and ~85 tests. Suggest starting with fs (40) — the validation helper there is reusable across the others.

Note: this is an honest-accounting gain, not a regression — #1924 stopped assert.throws from passing when nothing was thrown, revealing these were never actually validating. Real parity is ~28% (was 32.6% inflated).

Context: #800 --auto-optimize sweep, perry 0.5.1032.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparityNode.js compatibility / parity gaps

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions