Azure/azure-sdk-for-js

@azure/core-rest-pipeline accidentally broken for Node.js 14 after latest release

Closed this issue ยท 13 comments

  • Offending commit: bd7de1d
  • Package Name: @azure/core-rest-pipeline, but potentially other packages modified in the above commit can be affected
  • Package Version: 1.9.1
  • Operating system:
  • nodejs
    • 14.21.3

Describe the bug
Attempting to import SDK results in an exception caused by syntax that's not supported in node 14:

SyntaxError: Unexpected token '??='

To Reproduce

npm i @azure/core-rest-pipeline

Then run the following trivial script:

// index.js
require('')

to get the following error:

/[...]/node_modules/@azure/core-rest-pipeline/dist/commonjs/policies/multipartPolicy.js:99
            boundary ??= parsedBoundary;
                     ^^^

SyntaxError: Unexpected token '??='

Expected behavior
Since previous version of the package did support node 14, the new version should either stay backwards compatible or be published as a major release.

Additional context
I ended up here by debugging a problem with rush utility which used to work for me until yesterday and now it suddenly broke because of the reason explained above. Even though @rushstack/rush-azure-storage-build-cache-plugin is actually careful enough to only require patch updates from @azure/identity:

https://github.com/microsoft/rushstack/blob/main/rush-plugins/rush-azure-storage-build-cache-plugin/package.json#L21C1-L21C33

  "dependencies": {
    "@azure/identity": "~4.0.0",
    ...
  },

this doesn't help in this case since @azure/identity is more permissive:

https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/package.json#L108

  "dependencies": {
    "@azure/abort-controller": "^1.0.0",
    "@azure/core-auth": "^1.5.0",
    "@azure/core-client": "^1.4.0",
    "@azure/core-rest-pipeline": "^1.1.0",
    // ...
  },

A possible solution for this would be to publish a patch for @azure/core-rest-pipeline with the syntax reverted to a more compatible version.

Thank you for your feedback. Tagging and routing to the team member best able to assist.

Can someone resolve this quickly please?

Hey @apendua , thank you for reaching out and creating an issue for this.

I'm sorry to hear about the disruption, agree that can be frustrating.

Node 14 has been deprecated for 2.5 years and has reached its end-of-life roughly 1 year ago. Quoting our support policy:

The Azure SDK libraries for JavaScript will not be guaranteed to work on Node.js versions that have reached their end of life. Dropping support for such Node.js versions may be done without increasing the major version of the Azure SDK libraries.

I strongly recommend moving to a supported Node version to avoid incompatibilities, security concerns, and other painful surprises.

In the future, I may suggest the following options:

  1. Respecting engine incompatibility warnings to avoid surprises.
  2. Our client libraries could continue to work with previous versions of our core libraries as long as they are within the semver range the client library specifies. In that case, a lockfile could have prevented surprises here. Consider using lockfiles to avoid surprise dependency upgrades and give you time to upgrade.
  3. Finally, as a last resort, you could pin your version of @azure/core-rest-pipeline (or any core package) by installing it directly. In this case, npm install --save @azure/core-rest-pipeline@1.14.0 should pin your version of core-rest-pipeline to a prior version. I strongly recommend against this approach for security reasons, but it is an option to get you unblocked.

Feel free to reach out if you have any other questions, comments, or concerns!

Hey @apendua , thank you for reaching out and creating an issue for this.

I'm sorry to hear about the disruption, agree that can be frustrating.

Node 14 has been deprecated for 2.5 years and has reached its end-of-life roughly 1 year ago. Quoting our support policy:

The Azure SDK libraries for JavaScript will not be guaranteed to work on Node.js versions that have reached their end of life. Dropping support for such Node.js versions may be done without increasing the major version of the Azure SDK libraries.

I strongly recommend moving to a supported Node version to avoid incompatibilities, security concerns, and other painful surprises.

In the future, I may suggest the following options:

  1. Respecting engine incompatibility warnings to avoid surprises.
  2. Our client libraries could continue to work with previous versions of our core libraries as long as they are within the semver range the client library specifies. In that case, a lockfile could have prevented surprises here. Consider using lockfiles to avoid surprise dependency upgrades and give you time to upgrade.
  3. Finally, as a last resort, you could pin your version of @azure/core-rest-pipeline (or any core package) by installing it directly. In this case, npm install --save @azure/core-rest-pipeline@1.14.0 should pin your version of core-rest-pipeline to a prior version. I strongly recommend against this approach for security reasons, but it is an option to get you unblocked.

Feel free to reach out if you have any other questions, comments, or concerns!

or just major bump the suite when deprecating support for something? this was a minor bump

A dirty fix to this issue:
npm install --save @azure/core-rest-pipeline@1.14.0 @azure/logger@1.0.4
After installing all your modules.

  • Offending commit: bd7de1d

    • Package Name: @azure/core-rest-pipeline, but potentially other packages modified in the above commit can be affected

    • Package Version: 1.9.1

    • Operating system:

    • nodejs

      • 14.21.3

Describe the bug Attempting to import SDK results in an exception caused by syntax that's not supported in node 14:

SyntaxError: Unexpected token '??='

To Reproduce

npm i @azure/core-rest-pipeline

Then run the following trivial script:

// index.js
require('')

to get the following error:

/[...]/node_modules/@azure/core-rest-pipeline/dist/commonjs/policies/multipartPolicy.js:99
            boundary ??= parsedBoundary;
                     ^^^

SyntaxError: Unexpected token '??='

Expected behavior Since previous version of the package did support node 14, the new version should either stay backwards compatible or be published as a major release.

Additional context I ended up here by debugging a problem with rush utility which used to work for me until yesterday and now it suddenly broke because of the reason explained above. Even though @rushstack/rush-azure-storage-build-cache-plugin is actually careful enough to only require patch updates from @azure/identity:

https://github.com/microsoft/rushstack/blob/main/rush-plugins/rush-azure-storage-build-cache-plugin/package.json#L21C1-L21C33

  "dependencies": {
    "@azure/identity": "~4.0.0",
    ...
  },

this doesn't help in this case since @azure/identity is more permissive:

https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/package.json#L108

  "dependencies": {
    "@azure/abort-controller": "^1.0.0",
    "@azure/core-auth": "^1.5.0",
    "@azure/core-client": "^1.4.0",
    "@azure/core-rest-pipeline": "^1.1.0",
    // ...
  },

A possible solution for this would be to publish a patch for @azure/core-rest-pipeline with the syntax reverted to a more compatible version.

hi
can you suggest me a solution for @azure/storage-blob": "^12.2.0" package , its giving me same error ,
Should i downgrade the version of nodejs?

SyntaxError: Unexpected token '??='
pollUntilDone: (pollOptions) => (resultPromise ??= (async () => {

opt/app/node_modules/@azure/core-lro/dist/commonjs/poller/poller.js:81

Hi @iswarrawat - what version of node are you using currently?

Hi @maorleger. I have the same problem like @iswarrawat and I still need a support for node14.
SyntaxError: Unexpected token '??=' pollUntilDone: (pollOptions) => (resultPromise ??= (async () => {

Any idea to solve other than resigning from v14?

yes you can update that specific library in which the issue is coming
like i have this issue in opt/app/node_modules/@azure/core-lro/dist/commonjs/poller/poller.js
dependency :
@azure/core-lro

this is the library in which i am getting that issue so i update the version in which
this case is handled in different approach

(pollOptions) => (resultPromise ??= (async () => {

Hi @maorleger. I have the same problem like @iswarrawat and I still need a support for node14. SyntaxError: Unexpected token '??=' pollUntilDone: (pollOptions) => (resultPromise ??= (async () => {

Any idea to solve other than resigning from v14?

Hey @sfc-gh-pmotacki - the only thing I could think of if you must support node 14 is to use a transpiler like Babel that may be able to transpile the nullish coalescing operator to something that is supported in Node 14.

Aside from that, you could lock your core package dependencies to a previous version that supported Node 14 although we recommend against that #28918 (comment)

hi can you suggest me a solution for @azure/storage-blob": "^12.2.0" package , its giving me same error , Should i downgrade the version of nodejs?

SyntaxError: Unexpected token '??=' pollUntilDone: (pollOptions) => (resultPromise ??= (async () => {

opt/app/node_modules/@azure/core-lro/dist/commonjs/poller/poller.js:81

@iswarrawat I can confirm that #29111 - which was released for @azure/core-lro_2.7.2 in #29238 has fixed the same issue for my app, so you shouldn't need any additional fix at this point, just please try building it as usual.

I believe with yesterday's core release we have fixed the compiler target to be compatible with older Node again. Please let us know if you are still seeing syntax errors.