Skip to content

Following Typescript recipe with ts-node loader, with a type issue causes OOM/timeout errors (circumstantial) #3129

@danielgormly

Description

@danielgormly

What you're trying to do
Great tool, though we're having a problem in some of our projects that rely on ts-node loader. We know there's a timeout (or JS OOM error depending on file) but we don't know why without thorough investigation. We are following Typescript recipe in docs/recipes/typescript.md and using native ESM modules.

What happened
When there is a type issue in a test, adding number of lines to that test file appears to exponentially affect memory usage and test time.

What you expected to happen
Test(s) fails

I am testing this on my Macbook Air M1. I have tested with Node 18.12.0 and Node 16.17.

Minimal Reproduction:

package.json

{
  "name": "ava-repro",
  "scripts": {
    "test": "ava --config ava.config.js spec.ts"
  },
  "type": "module",
  "dependencies": {
    "ava": "^5.0.1",
    "ts-node": "^10.9.1",
    "typescript": "^4.8.4"
  }
}

ava.config.js

export default {
    concurrency: 1,
    timeout: '120s',
    nodeArguments: ['--loader=ts-node/esm'],
    extensions: { ts: 'module', },
  };

tsconfig.js

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "ES2020",
    "moduleResolution": "node"
  },
  "exclude": ["node_modules"]
}

working.spec.ts

import test, { ExecutionContext } from 'ava';

test.skip('broken test', (t: ExecutionContext) => {
    const test = 1;
    console.log(test + 1)
    broken() // reference error, does not pass ts compilation
});

broken.spec.ts

import test, { ExecutionContext } from 'ava';

test.skip('broken test', (t: ExecutionContext) => {
    const test = 1;
    console.log(test + 1)
    console.log(test + 1)
    console.log(test + 1)
    console.log(test + 1)
    console.log(test + 1) // test time & memory usage starts to increase dramatically when i add about 6
    console.log(test + 1) // gets exponentially worse the more of these you add
    console.log(test + 1) // oom errors around 7 or so extra lines
    console.log(test + 1) // they can be in the same test or in others in the same file
    broken() // the reference error that causes the issue
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions