-
Notifications
You must be signed in to change notification settings - Fork 387
Disable unnecessary and heavy downcompilation of async/await syntax #657
Comments
This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days. |
Still relevant with the latest version of this library: https://unpkg.com/browse/@shopify/shopify-api@6.2.0/lib/auth/oauth/oauth.js |
This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days. |
This is still relevant with the latest version of this library: https://unpkg.com/browse/@shopify/shopify-api@7.0.0/lib/auth/oauth/oauth.js Note that Node v14 is also end of life as today, the lowest version of Node that is still actively maintained is v16, which definitely has async/await support. like every version of Node since v8. Could you please review your build settings and see if it is really still necessary to downcompile the async functions? |
This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days. |
I think that every platform that Shopify supports also supports async/await syntax natively. So I think the transpilation does not bring any benefits and has several downsides:
|
I would like to add that using a pre async/await Even if you do want to wrap everything in try/catch, in a large code base finding them all can be challenging when the stack doesn't tell you which code actually made the call that went wrong. |
This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days. |
I agree completely with @public's comment above: #657 (comment) The latest version of shopify-api package on NPM still has this issue: https://unpkg.com/browse/@shopify/shopify-api@8.0.1/lib/auth/oauth/oauth.js |
This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days. |
Not stale, still an issue in the latest version: https://unpkg.com/browse/@shopify/shopify-api@8.1.1/lib/auth/oauth/oauth.js The compiled npm code looks like: function validQuery({ config, query, stateFromCookie, }) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return ((yield (0, hmac_validator_1.validateHmac)(config)(query)) &&
(0, safe_compare_1.safeCompare)(query.state, stateFromCookie));
});
} While, as far as I am aware, any runtime Shopify supports could handle the native async syntax in the original source: async function validQuery({
config,
query,
stateFromCookie,
}: {
config: ConfigInterface;
query: AuthQuery;
stateFromCookie: string;
}): Promise<boolean> {
return (
(await validateHmac(config)(query)) &&
safeCompare(query.state!, stateFromCookie)
);
} Using Shopify APIs has plenty of challenges for regular devs as it is. If this this compilation setting is changed you can get the following benefits:
|
We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests. You can add a comment to remove the label if it's still relevant, and we can re-evaluate it. |
Hey folks, thanks for your patience. As part of merging our repos / revamping the build process, we've also updated our TS target so hopefully this will be improved. Please let us know in https://github.com/Shopify/shopify-app-js if you still run into problems! |
Issue summary
The stack traces for shopify API are a bit on the obtuse side, for example I just ran into this:
@shopify/shopify-api
version: 6.0.2This is kind of compounded by the fact that some issues must be debugged in a production configuration where source maps may not be available.
We can see that the source async await is downcompiled into generator syntax:
https://unpkg.com/browse/@shopify/shopify-api@6.0.2/lib/auth/oauth/oauth.js
Expected behavior
See if it is actually necessary to downcompile the async/await syntax in the NPM library?
If it can be preserved as is, this will give more useful stack traces.
Async/await has been supported in Node since v8.
The oldest version of Node that is still in maintenance is v14.
Additionally, is is quite easy these days for the end user to downcompile async/await syntax for a runtime that does not support it.
The text was updated successfully, but these errors were encountered: