Skip to content

Consider limiting the number of AsyncContext variables allocated #50

Open
@littledan

Description

@littledan

@syg expressed the concern at TC39 that JS developers may allocate too many AsyncContext variables, slowing down their programs and creating unmanageable expectations on JS engines to make it fast somehow. In general, I think the best practice is for each library or framework to create just one AsyncContext variable. But could we actually enforce a limit on the total number of variables created?

In general, in JS, the specification does not indicate hard limits for real resources like the heap size or the callstack size--it's just implicit that the JS engine may throw an exception or terminate if unspecified limits are exceeded. On the other hand, WebAssembly has standardized its implementation-defined limits at https://webassembly.github.io/spec/js-api/#limits . I wonder if, in JS, we could agree on implementation-defined limits for certain aspects of certain new features, like this.

What if we had an overall limit of AsyncContext variables, after which an exception is thrown if JS tries to allocate more? Maybe this could be 1000 or 10000--I really can't imagine valid use case requiring more than that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions