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

retry module no longer works after minification #7866

Open
DeMoorJasper opened this issue Mar 25, 2022 · 3 comments
Open

retry module no longer works after minification #7866

DeMoorJasper opened this issue Mar 25, 2022 · 3 comments

Comments

@DeMoorJasper
Copy link
Member

🐛 bug report

After compiling an application with retry in it, you get an error saying Cannot read properties of undefined (reading 'createTimeout') originating from this file: https://unpkg.com/browse/retry@0.13.1/lib/retry.js

🎛 Configuration (.babelrc, package.json, cli command)

No config

🤔 Expected Behavior

It should work the same in production as in development

😯 Current Behavior

Only works fine in development, in production it throws Cannot read properties of undefined (reading 'createTimeout') when trying to use the library

💁 Possible Solution

Not sure yet, just gonna write my own fork of retry for now...

🔦 Context

Trying to use p-retry which uses retry under the hood

@mischnic
Copy link
Member

I could have sworn there's an existing issue about this problem, but I can't find it now..

The problem is that

exports.operation = function(options) {
  var timeouts = exports.timeouts(options);
  // ...
}

exports.timeouts = function(options) {
  // ...
    timeouts.push(this.createTimeout(i, opts));
  // ...
}

becomes

$65d25f58acbeda74$export$7b8f6cec25af9dd = function(options) {
  var timeouts = $65d25f58acbeda74$export$968081c158f72864(options);
  // ...
};

$65d25f58acbeda74$export$968081c158f72864 = function(options) {
  // ...
    timeouts.push(this.createTimeout(i, opts)); // this is undefined
  // ...
};

And surprisingly, there is no special case for this with ESM

export function a() {
	this.b();
}

export function b() {
	console.log("b");
}

only works if called as ns.a(), not with b().

Not sure what to do about this without deopting these direct calls of exported values.

@kirillsavko
Copy link

Hello!
Any updates about this issue?
I'd want to use parcel, but because of the problem with the retry library, I cannot do it 😔

@dg-zlyde
Copy link

I stumbled across this issue just now.
I have the same problem when using langchainjs lib which has retry as a dependency.

You can use the --no-scope-hoist option in your build command. Then this will not happen and works for me.
Not a top solution as there is a reason why parcel has scope hoisting, but seems problematic in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants