Esri / arcgis-rest-js

compact, modular JavaScript wrappers for the ArcGIS REST API
https://developers.arcgis.com/arcgis-rest-js/
Apache License 2.0
353 stars 119 forks source link

Unable to upload item data with addItemData() #1033

Open haoliangyu opened 2 years ago

haoliangyu commented 2 years ago

Describe the bug

I am trying to use the addItemData function in node 16 to upload file data to an already created item. It doesn't throw any error but the file is actually not uploaded. When I try to download the item file, it shows a Item does not have a file. error page.

This bug happens at rest-js 4.x.

Reproduction

You can reproduce the problem by running the repository https://github.com/haoliangyu/arcgis-rest-js-node-16-bug. You can run volta run yarn and volta run node index.js to reproduce the problem.

Logs

There is no error log.

System Info

System:
    OS: macOS 12.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 581.50 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.18.0 - ~/.volta/tools/image/node/16.18.0/bin/node
    Yarn: 1.22.10 - ~/.volta/tools/image/yarn/1.22.10/bin/yarn
    npm: 8.19.2 - ~/.volta/tools/image/npm/8.19.2/bin/npm
  Browsers:
    Chrome: 106.0.5249.119
    Safari: 15.6.1
  npmPackages:
    @esri/arcgis-rest-request: ^4.0.0 => 4.1.1

Additional Information

No response

haoliangyu commented 2 years ago

At rest-js 2.x and 3.x, there is another problem with the addItemData function. It may cause the socket hang up error in the update request. I have seen a few issues related to the form-data library and nodejs Readable stream: https://github.com/form-data/form-data/issues/520, https://github.com/form-data/form-data/issues/503, https://github.com/form-data/form-data/issues/508. But since rest-js 2.x and 3.x are no longer supported, I only submit the issue for 4.x.