jhurliman / node-rate-limiter

A generic rate limiter for node.js. Useful for API clients, web crawling, or other tasks that need to be throttled
MIT License
1.5k stars 132 forks source link

'process' is not defined #71

Closed yuittti closed 3 years ago

yuittti commented 3 years ago

After migrating to webpack 5 the call of the removeTokens methods crashes the app with the error process is not defined

import { RateLimiter } from 'limiter';

const maxRequestsPerSecond = 10;
const myLimiter = new RateLimiter(maxRequestsPerSecond, 'second');

const someMethod = async () => {
  await new Promise<void>(resolve => {
    myLimiter.removeTokens(1, () => resolve());
  }
}
yuittti commented 3 years ago

The solution was found - In webpack 5 automatic node.js polyfills are removed https://github.com/webpack/webpack/issues/11282 https://stackoverflow.com/questions/65018431/webpack-5-uncaught-referenceerror-process-is-not-defined