single-spa / import-map-deployer

A manifest deployment service for sofe/import maps
Apache License 2.0
191 stars 63 forks source link

Azure blob storage issues after 4.6.0 -> 4.6.1 update #167

Closed joakimlemb closed 1 week ago

joakimlemb commented 2 weeks ago

After updating from 4.6.0 to 4.6.1 we are getting the following error:

2024-09-17T04:41:33.5625408Z TypeError: this.source.on is not a function
2024-09-17T04:41:33.5626232Z at RetriableReadableStream.setSourceDataHandler (/www/node_modules/@azure/storage-blob/dist/index.js:10723:21)
2024-09-17T04:41:33.5626280Z at new RetriableReadableStream (/www/node_modules/@azure/storage-blob/dist/index.js:10711:15)
2024-09-17T04:41:33.5626333Z at new BlobDownloadResponse (/www/node_modules/@azure/storage-blob/dist/index.js:10822:35)
2024-09-17T04:41:33.5626370Z at BlobClient.<anonymous> (/www/node_modules/@azure/storage-blob/dist/index.js:12982:47)
2024-09-17T04:41:33.5626403Z at step (/www/node_modules/tslib/tslib.js:141:27)
2024-09-17T04:41:33.5626509Z at Object.next (/www/node_modules/tslib/tslib.js:122:57)
2024-09-17T04:41:33.5626547Z at fulfilled (/www/node_modules/tslib/tslib.js:112:62)
2024-09-17T04:41:33.5626583Z at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-09-17T04:41:33.5641075Z Killing web server because initial health check failed

Similear issues we found: https://github.com/Azure/azure-sdk-for-js/issues/25552 https://github.com/oven-sh/bun/issues/4067

joeldenning commented 1 week ago

Investigation:

import-map-deployer's initial health check reads the import map, then writes it, then reads it again. Based on the BlobDownloadResponse portion of the stacktrace, my guess is that it's failing during the read. This line might be the line calling into @azure/storage-blob and triggering the error.

https://github.com/single-spa/import-map-deployer/blob/e84f66033ae6d17cf58b26f74106a7b47cb80629/src/io-methods/azure.js#L57

import-map-deployer upgraded some dependencies, but the dependency for @azure/storage-blob was not upgraded (see git blame). Perhaps a dependency of azure/storage-blob was upgraded. I will try to replicate the issue.

joeldenning commented 1 week ago

I have replicated the issue locally and fixed it. It's related to Azure Storage's tslib dependency not working in Node 20. Upgrading to @azure/storage-blob@12.24.0 fixes it.

Unfortunately, the import-map-deployer tests don't work because the @azure/core-rest-pipeline dependency doesn't function the same in Jest as in normal Node. See possibly-related https://github.com/Azure/azure-sdk-for-js/issues/28940

joeldenning commented 1 week ago

Released the fix for this in 5.0.0. The upgrade to Node 20 is a breaking change to import-map-deployer and shouldn't have been released as a patch.

joakimlemb commented 1 week ago

Upgrading to 5.0 fixed our issue, thanks for the fast solution @joeldenning