msgraph-sdk-javascript icon indicating copy to clipboard operation
msgraph-sdk-javascript copied to clipboard

Verify compatibility with Node 18

Open nikithauc opened this issue 3 years ago • 1 comments

-[] fetch is introduced globally in Node 18. Verify the compatibility in 3.0.0 and 4.x-previews -[] Verify stream upload using LargeFileUploadTask

nikithauc avatar Sep 28 '22 00:09 nikithauc

Ran into a bit of an issue with the putStream method, which I think is related to Node 18. With the following code:

const stream = fs.createReadStream('the path');
await client.api(...).putStream(stream);

Get the following error: Could not upload file to Sharepoint RequestInit: duplex option is required when sending a body.

Seems like this is related to changes in the Fetch spec: https://github.com/nodejs/node/issues/46221

Thankfully, we can pass in the duplex: "half" Fetch option i.e.

await client.api(...)
  .options({ duplex: 'half' })
  .putStream(stream);

However, this seems a little clunky and is not very obvious or ergonomic. Would suggest automatically applying this option internally (if it's not been set).

ntsim avatar Nov 18 '23 12:11 ntsim