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

Aborting requests throws a ReferenceError in node.js #45

Open
solmsted opened this issue May 12, 2018 · 2 comments
Open

Aborting requests throws a ReferenceError in node.js #45

solmsted opened this issue May 12, 2018 · 2 comments

Comments

@solmsted
Copy link

solmsted commented May 12, 2018

Using node.js v8.11.1

Simple example to reproduce:

const PromiseThrottle = require('promise-throttle'),
    promiseThrottle = new PromiseThrottle({
        promiseImplementation: Promise,
        requestsPerSecond: 1
    });

promiseThrottle.add(() => Promise.resolve(), {
    signal: {
        aborted: true
    }
});

This results in an error: UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: DOMException is not defined

@JMPerez
Copy link
Owner

JMPerez commented May 13, 2018

You are right, @solmsted. As far as I know, AbortSignal and AbortController are not supported in Node.JS. One reason is that DOMException is not defined in Node.JS.

According to the spec:

APIs that rely upon AbortController are encouraged to respond to abort() by rejecting any unsettled promise with a new "AbortError" DOMException.

At this point, the library either triggers an early exception when trying to use a signal in node, or it throws a regular Exception when aborting in node.

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

No branches or pull requests

3 participants
@JMPerez @solmsted and others