Error "No such built-in module: node:stream/promises" throws when storing an uploaded file to temp storage

I’m building a workflow from Thomas Frank’s audio transcription. Step Two (which is a Node.js trigger) stores the file from step one (which is a Dropbox trigger) into temp storage, but failing even though it worked previously today and the previous week. To verify and isolate the issue, I created a new workflow and verified it also fails.

I have to emphasize that this has been working up until an hour ago and I cannot identify anything that has changed in the workflow or external sources. Step One, a folder monitor that downloads new files, still works as expected.

Please advise.

Below is the full error

Error

Error: No such built-in module: node:stream/promises

DETAILS

Error: Error: No such built-in module: node:stream/promises
    at handleError (/var/task/common.js:38:40)
    at Runner.runUserCode (file:///var/task/lambda_handler.mjs:866:9)
    at async Runner.run (file:///var/task/lambda_handler.mjs:697:5)
    at async Runtime.handler (file:///var/task/lambda_handler.mjs:914:22)

Hi @rawitten,

It looks like the error message you’re seeing is related to a missing built-in module in Node.js. Specifically, the module node:stream/promises is not found.

This error can occur if you’re using a version of Node.js that doesn’t include this module, or if there’s an issue with the environment where your code is running.

To troubleshoot this issue, I would recommend the following steps:

  1. Check the version of Node.js you’re using in your workflow. Make sure it’s a version that includes the node:stream/promises module. You can find more information about Node.js versions and compatibility in the Pipedream documentation.

  2. If you’re using a specific version of Node.js, try updating to the latest version to see if that resolves the issue.

  3. Verify that the environment where your code is running has the necessary dependencies and modules installed. This includes any additional packages or libraries that your code relies on.

  4. If you’re still experiencing issues, I would recommend reaching out to Pipedream support for further assistance. They can help you troubleshoot the issue and provide guidance on how to resolve it.

I hope this helps! Let me know if you have any further questions.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.

@pi The version of node.js is determined by the pipedream environment. The code was working earlier today. what is the most likely cause of this code throwing an error now when it was working earlier today?

Youtube Data Api component also stopped working for me today with the same error:

Error: No such built-in module: node:stream/promises

DETAILS

Error: Error: No such built-in module: node:stream/promises
    at handleError (/var/task/common.js:38:40)
    at Runner.runUserCode (file:///var/task/lambda_handler.mjs:866:9)
    at async Runner.run (file:///var/task/lambda_handler.mjs:697:5)
    at async Runtime.handler (file:///var/task/lambda_handler.mjs:914:22)

@rawitten Could you do me a favor and change this line in the code:

import got from "got";

to:

import got from "got@12.6.1";

@kosta0124 we’ll look into the component issue.

For context, got shipped a new version of their package that’s incompatible with our Node v14 runtime, and requires Node 16. Since we download the latest version of npm packages on deploy (of workflows and sources), this issue only showed up now, since they just shipped a new version.

I’m fixing this on the platform side by mapping all un-versioned references for got to 12.6.1, to ensure this isn’t an issue for other users.

I tried import got from “got@12.6.1”; and still getting the same error

import got from "got";

should work again. We’re mapping the default version to the latest known working version of got, 12.4.1.

looks to be working !

Here’s what I’m seeing now:

Looks like “got" got gone? ;-\

Here’s my workflow:

[
embed-image.5f8189f7.png

Sign Up
pipedream.com

](https://pipedream.com/new?h=tch_3xxfdG)

I’m still dead in the water. The step still fails, though with a different error (see below). This code was working yesterday morning. Any thoughts?

at Request._onResponseBase (file:///tmp/pdg/dist/code/c21e7296192b7c2bcfd791b44fbb77aecf333f0676f478a70df37d961f9b659f/node_modules/.pnpm/got@12.4.1/node_modules/got/dist/source/core/index.js:691:31)
at Request._onResponse (file:///tmp/pdg/dist/code/c21e7296192b7c2bcfd791b44fbb77aecf333f0676f478a70df37d961f9b659f/node_modules/.pnpm/got@12.4.1/node_modules/got/dist/source/core/index.js:750:24)
at ClientRequest.null (file:///tmp/pdg/dist/code/c21e7296192b7c2bcfd791b44fbb77aecf333f0676f478a70df37d961f9b659f/node_modules/.pnpm/got@12.4.1/node_modules/got/dist/source/core/index.js:768:23)
at Object.onceWrapper (events.js:520:26)
at ClientRequest.emit (events.js:412:35)
at HTTPParser.parserOnIncomingClient (_http_client.js:647:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:127:17)
at TLSSocket.socketOnData (_http_client.js:515:22)
at TLSSocket.emit (events.js:400:28)
at null.addChunk (internal/streams/readable.js:293:12)
{
input: undefined,
code: ‘ERR_NON_2XX_3XX_RESPONSE’,
timings: {
start: 1687373490178,
socket: 1687373490181,
lookup: 1687373490183,
connect: 1687373490185,
secureConnect: 1687373490187,
upload: 1687373490187,
response: 1687373490200,
end: 1687373490202,
error: undefined,
abort: undefined,
phases: {
wait: 3,
dns: 2,
tcp: 2,
tls: 2,
request: 0,
firstByte: 13,
download: 2,
total: 24
}
},
name: ‘HTTPError’,
options: {
request: undefined,
agent: { http: undefined, https: undefined, http2: undefined },
h2session: undefined,
decompress: true,
timeout: {
connect: undefined,
lookup: undefined,
read: undefined,
request: undefined,
response: undefined,
secureConnect: undefined,
send: undefined,
socket: undefined
},
prefixUrl: ‘’,
body: undefined,
form: undefined,
json: undefined,
cookieJar: undefined,
ignoreInvalidCookies: false,
searchParams: undefined,
dnsLookup: undefined,
dnsCache: undefined,
context: {},
hooks: {
init: [],
beforeRequest: [],
beforeError: [],
beforeRedirect: [],
beforeRetry: [],
afterResponse: []
},
followRedirect: true,
maxRedirects: 10,
cache: undefined,
throwHttpErrors: true,
username: ‘’,
password: ‘’,
http2: false,
allowGetBody: false,
headers: {
‘user-agent’: ‘got (GitHub - sindresorhus/got: 🌐 Human-friendly and powerful HTTP request library for Node.js)’,
‘accept-encoding’: ‘gzip, deflate, br’
},
methodRewriting: false,
dnsLookupIpVersion: undefined,
parseJson: [Function: parse],
stringifyJson: [Function: stringify],
retry: {
limit: 2,
methods: [ ‘GET’, ‘PUT’, ‘HEAD’, ‘DELETE’, ‘OPTIONS’, ‘TRACE’ ],
statusCodes: [
408, 413, 429, 500,
502, 503, 504, 521,
522, 524
],
errorCodes: [
‘ETIMEDOUT’,
‘ECONNRESET’,
‘EADDRINUSE’,
‘ECONNREFUSED’,
‘EPIPE’,
‘ENOTFOUND’,
‘ENETUNREACH’,
‘EAI_AGAIN’
],
maxRetryAfter: undefined,
calculateDelay: [Function: calculateDelay],
backoffLimit: Infinity,
noise: 100
},
localAddress: undefined,
method: ‘GET’,
createConnection: undefined,
cacheOptions: {
shared: undefined,
cacheHeuristic: undefined,
immutableMinTimeToLive: undefined,
ignoreCargoCult: undefined
},
https: {
alpnProtocols: undefined,
rejectUnauthorized: undefined,
checkServerIdentity: undefined,
certificateAuthority: undefined,
key: undefined,
certificate: undefined,
passphrase: undefined,
pfx: undefined,
ciphers: undefined,
honorCipherOrder: undefined,
minVersion: undefined,
maxVersion: undefined,
signatureAlgorithms: undefined,
tlsSessionLifetime: undefined,
dhparam: undefined,
ecdhCurve: undefined,
certificateRevocationLists: undefined
},
encoding: undefined,
resolveBodyOnly: false,
isStream: true,
responseType: ‘text’,
url: URL {
href: ‘https://uc6fa8c74f3cd98af6d117bbea34.dl.dropboxusercontent.com/cd/0/get/B-Z4daSBMLv93D8dKnuLINzAKkzqcXwAAW3N3lePveJH6ZwFVNlK43QJB-Fi1vvRNgJnZNukiz7-k5wLCWB29_SLB4tIbCBZYPCnvVPYJzxsPO6kbW0zNBHPLEmsnHFrSUoFeq3Rxbpk4I4vNMrY5VXXtFRW5ysyA6JmmAmHWIL2DWC0fLyPwb6g0M5Xsw8SLAk/file’,
origin: ‘https://uc6fa8c74f3cd98af6d117bbea34.dl.dropboxusercontent.com’,
protocol: ‘https:’,
username: ‘’,
password: ‘’,
host: ‘uc6fa8c74f3cd98af6d117bbea34.dl.dropboxusercontent.com’,
hostname: ‘uc6fa8c74f3cd98af6d117bbea34.dl.dropboxusercontent.com’,
port: ‘’,
pathname: ‘/cd/0/get/B-Z4daSBMLv93D8dKnuLINzAKkzqcXwAAW3N3lePveJH6ZwFVNlK43QJB-Fi1vvRNgJnZNukiz7-k5wLCWB29_SLB4tIbCBZYPCnvVPYJzxsPO6kbW0zNBHPLEmsnHFrSUoFeq3Rxbpk4I4vNMrY5VXXtFRW5ysyA6JmmAmHWIL2DWC0fLyPwb6g0M5Xsw8SLAk/file’,
search: ‘’,
searchParams: URLSearchParams {},
hash: ‘’
},
pagination: {
transform: [Function: transform],
paginate: [Function: paginate],
filter: [Function: filter],
shouldContinue: [Function: shouldContinue],
countLimit: Infinity,
backoff: 0,
requestLimit: 10000,
stackAllItems: false
},
setHost: true,
maxHeaderSize: undefined,
signal: undefined,
enableUnixSockets: true
}
}

Here’s the code:

mport stream from “stream”;
import { promisify } from “util”;
import fs from “fs”;
import got from “got”;

export default defineComponent({
async run({ steps, $ }) {

// Workflow only supports files <100mb, so break out if the file is larger.
if (steps.trigger.event.size > 100000000) {
throw new Error(“File is too large. Files must be mp3 or m4a filels under 100mb”)
}

try {
// Define the mimetype
const mime = steps.trigger.event.path_lower.match(/.\w+$/)[0]

// Check if the mime type is supported (mp3 or m4a)
if (mime !== ‘.mp3’ && mime !== ‘.m4a’) {
throw new Error(“Unsupported file type. Only mp3 and m4a files are supported.”);
}

// Define the tmp file path
const tmpPath = /tmp/recording${mime}

// Download the audio recording from Dropbox to tmp file path
const pipeline = promisify(stream.pipeline);
await pipeline(
got.stream(steps.trigger.event.link),
fs.createWriteStream(tmpPath)
);

// Create a results object
const results = {
“tmpPath”: tmpPath,
“mimetype”: mime
}

return results
} catch (error) {
// Log the error and return an error message or handle the error as required
console.error(error);
throw error;
}
}
})

I’m now receiving a 404 error.


HTTPError
Response code 404 (Not Found)

DETAILS
    at Request._onResponseBase (file:///tmp/__pdg__/dist/code/03843e6a7ec7bb29bdeefb4ce45739ad1577c122b4e540cca8bc291d0141215d/node_modules/.pnpm/got@12.4.1/node_modules/got/dist/source/core/index.js:691:31)
    at Request._onResponse (file:///tmp/__pdg__/dist/code/03843e6a7ec7bb29bdeefb4ce45739ad1577c122b4e540cca8bc291d0141215d/node_modules/.pnpm/got@12.4.1/node_modules/got/dist/source/core/index.js:750:24)
    at ClientRequest.null (file:///tmp/__pdg__/dist/code/03843e6a7ec7bb29bdeefb4ce45739ad1577c122b4e540cca8bc291d0141215d/node_modules/.pnpm/got@12.4.1/node_modules/got/dist/source/core/index.js:768:23)
    at Object.onceWrapper (events.js:520:26)
    at ClientRequest.emit (events.js:412:35)
    at HTTPParser.parserOnIncomingClient (_http_client.js:647:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:127:17)
    at TLSSocket.socketOnData (_http_client.js:515:22)
    at TLSSocket.emit (events.js:400:28)
    at null.addChunk (internal/streams/readable.js:293:12)

I’m also receiving an Active Handle warning.

6/21/2023, 4:45:04 PM

ACTIVE_HANDLE`This step was still trying to run code when the step ended. Make sure you promisify callback functions and await all Promises. (Reason: FSReqCallback, Learn more: https://pipedream.com/docs/code/nodejs/async/)`

The support doc indicates this should be reported as a bug.

The first step, which responds to a file being placed in a folder on dropbox, runs successfully, so the file is confirmed to exist.

Thoughts? It’s been over 24hrs since I’ve been able to run this workflow.

@rawitten Unfortunately since we didn’t author this workflow, I’m not sure the exact cause of the issue. But based on the error, it looks like the step is trying to fetch data from the link at steps.trigger.event.link, which looks like it’s from Dropbox, correct?

Does that link work for you? Does it have something to do with the permissions of the Dropbox file? Since this step doesn’t authenticate with Dropbox, do you have to make the file public to access it? I’m not sure how Dropbox handles this, just trying to share some ideas.

This doesn’t look like an issue with the Pipedream platform, but others may be able to chime in with suggestions.

Thanks. The problem has resolved.

How did you solve the issue. I have the same problem

The error seems to be related to the ‘node:stream/promises’ module. Did you recently update any dependencies or the Node.js version? Sometimes these glitches pop up after an unnoticed tweak. Double-checking those might help. Also, any chance there’s an issue with the temp storage setup?

Pipedream’s vendor caused the issue. When that was fixed, my problem went away.