sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.27k stars 935 forks source link

TypeError: The payload has been already provided on node 17 #2009

Closed bangbang93 closed 2 years ago

bangbang93 commented 2 years ago

Describe the bug

Actual behavior

TypeError: The payload has been already provided
    at Request.onLockedWrite (file:///home/bangbang93/Development/temp/node_modules/got/dist/source/core/index.js:497:19)
    at ReadStream.<anonymous> (node:internal/streams/pipeline:323:31)
    at Object.onceWrapper (node:events:641:28)
    at ReadStream.emit (node:events:539:35)
    at ReadStream.emit (node:domain:475:12)
    at endReadableNT (node:internal/streams/readable:1342:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

works on node 16.14.0 tests fails on node 17

  Uncaught exception in test/progress.ts

  TypeError: The payload has been already provided

  › Request.onLockedWrite (file://source/core/index.ts:557:10)

  Uncaught exception in test/progress.ts

  TypeError: The payload has been already provided

  › Request.onLockedWrite (file://source/core/index.ts:557:10)

  Uncaught exception in test/stream.ts

  TypeError: The payload has been already provided

  › Request.onLockedWrite (file://source/core/index.ts:557:10)

  ─

  525 tests passed
  3 known failures
  4 tests skipped
  3 uncaught exceptions

Expected behavior

post with stream

Code to reproduce

import {createReadStream} from "fs";
import {fileURLToPath} from "url";
import {pipeline} from "stream/promises";
import got from "got";

const stream = createReadStream(fileURLToPath(import.meta.url))
await pipeline(stream, got.stream.post('https://example.com'))

Checklist

szmarczak commented 2 years ago

There are some breaking changes in 17 which we have not addressed yet. Please stick by 16 for now.

SudhirRamaniOD commented 2 years ago

Is this expected behavior with NodeJS v17 and Got v12.0.3 every time?

szmarczak commented 2 years ago

No, this is not expected behavior. Please note that Node.js 17 is a breaking release. This will be fixed in the near future.

SudhirRamaniOD commented 2 years ago

Is there any working sample reference for uploading stream in chunks using got and pipe?

szmarczak commented 2 years ago

Fixed in https://github.com/sindresorhus/got/releases/tag/v12.0.4

pwespi commented 1 year ago

@szmarczak I have this issue in v11. Any chance you could take a look at https://github.com/sindresorhus/got/pull/2236? Thanks for your great work!