When I import and use:
import { createConfidentialOauthClient } from "@osdk/oauth";
const auth = createConfidentialOauthClient(clientId, clientSecret, url, scopes);
I get the following error:
Error initializing bundle containing user code. Common causes include imports of libraries that rely on browser or Node.js APIs, which do not exist in the V8 environment user code is evaluated in. See the provided stack trace for further information..
Error Parameters: {
"message": "TextEncoder is not defined",
"stacktrace": "ReferenceError: TextEncoder is not defined\n at Module.30121 (/scratch/standalone/f332e8c3-d026-40cc-ab6a-994e0dd3a354/code-assist/contents/functions-typescript/dist/Functions.bundle.js:51728:17)\n at __webpack_require__ (/scratch/standalone/f332e8c3-d026-40cc-ab6a-994e0dd3a354/code-assist/contents/functions-typescript/dist/Functions.bundle.js:54749:42)\n at Object.96622 (/scratch/standalone/f332e8c3-d026-40cc-ab6a-994e0dd3a354/code-assist/contents/functions-typescript/dist/Functions.bundle.js:41020:17)\n at __webpack_require__ (/scratch/standalone/f332e8c3-d026-40cc-ab6a-994e0dd3a354/code-assist/contents/functions-typescript/dist/Functions.bundle.js:54749:42)\n at Object.13261 (/scratch/standalone/f332e8c3-d026-40cc-ab6a-994e0dd3a354/code-assist/contents/functions-typescript/dist/Functions.bundle.js:41005:14)\n at __webpack_require__ (/scratch/standalone/f332e8c3-d026-40cc-ab6a-994e0dd3a354/code-assist/contents/functions-typescript/dist/Functions.bundle.js:54749:42)\n at Object.94858 (/scratch/standalone/f332e8c3-d026-40cc-ab6a-994e0dd3a354/code-assist/contents/functions-typescript/dist/Functions.bundle.js:40912:14)\n at __webpack_require__ (/scratch/standalone/f332e8c3-d026-40cc-ab6a-994e0dd3a354/code-assist/contents/functions-typescript/dist/Functions.bundle.js:54749:42)\n at Object.60835 (/scratch/standalone/f332e8c3-d026-40cc-ab6a-994e0dd3a354/code-assist/contents/functions-typescript/dist/Functions.bundle.js:41491:21)\n at __webpack_require__ (/scratch/standalone/f332e8c3-d026-40cc-ab6a-994e0dd3a354/code-assist/contents/functions-typescript/dist/Functions.bundle.js:54749:42)\n at (<isolated-vm boundary>)\n at /scratch/asset-install/a3c74a0ea403abb64ff702a77492b2bc/node_modules/@foundry/functions-typescript-runtime-lib/dist/isolate/Isolate.js:104:27"
}
ReferenceError: {Redacted message: see unsafe logs}
{Redacted stacktrace: see unsafe logs}
This is due to the runtime in functions being some custom runtime that the functions team created, which is either outdated or excludes specific node libraries. While I know functions V2 will fix these issues, it is not production-ready. It’s missing support to external sources and other key features.
Why are we using the OSDK in functions? Because we are triggering actions in our partners’ Foundry stack. In this case a request for proposal.
This needs to get fixed. You can not leave developers without support for your own SDKs. While I might be able to work around this issue using compute modules, I am very frustrated to have to resort to this.