fawwaz
fawwaz16mo ago

ReferenceError: structuredClone is not defined

Seems I can't use structuredClone inside convex, but according to my convex tsconfig, there shouldn't be a problem, right?
{
/* This TypeScript project config describes the environment that
* Convex functions run in and is used to typecheck them.
* You can modify it, but some settings required to use Convex.
*/
"compilerOptions": {
/* These settings are not required by Convex and can be modified. */
"allowJs": true,
"strict": true,

/* These compiler options are required by Convex */
"target": "ESNext",
"lib": ["ES2021", "dom"],
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"module": "ESNext",
"moduleResolution": "Node",
"isolatedModules": true,
"noEmit": true,
"paths": {
"@domainLayer/*": ["../src/domain-layer/*"],
"@/*": ["../src/*"],
"@convex/*": ["./*"]
}
},
"include": ["./**/*", "../src/components/email"],
"exclude": ["./_generated"]
}
{
/* This TypeScript project config describes the environment that
* Convex functions run in and is used to typecheck them.
* You can modify it, but some settings required to use Convex.
*/
"compilerOptions": {
/* These settings are not required by Convex and can be modified. */
"allowJs": true,
"strict": true,

/* These compiler options are required by Convex */
"target": "ESNext",
"lib": ["ES2021", "dom"],
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"module": "ESNext",
"moduleResolution": "Node",
"isolatedModules": true,
"noEmit": true,
"paths": {
"@domainLayer/*": ["../src/domain-layer/*"],
"@/*": ["../src/*"],
"@convex/*": ["./*"]
}
},
"include": ["./**/*", "../src/components/email"],
"exclude": ["./_generated"]
}
2 Replies
erquhart
erquhart16mo ago
Is Typescript not recognizing it or is it just failing at runtime?
lee
lee16mo ago
it looks like convex's runtime doesn't implement structuredClone. i'll put it on the list for us to implement. in the meantime you may be able to use a polyfill (like this https://github.com/ungap/structured-clone), or move it to a Node.js action, or find another way to copy it more manually

Did you find this page helpful?