https://pulumi.com logo
#automation-api
Title
# automation-api
b

bumpy-toothbrush-18988

07/17/2023, 2:21 AM
Hello, I'm attempting to create a Dynamic Resource Provider resource using the typescript automation api from within a vscode extension (vscode:1.80.1, Node.js: 16.17.1) and am receiving the following error. Standard Resource Provider resources work fine without error and running the same dynamic resource code outside of vscode works fine. My vscode extension for testing is here: https://github.com/korosccj/pulumi-test Any help/guidance would be appreciated.
Copy code
Pulumi Test Extension Running
extensionHostProcess.js:105
Updating (pulumi-test):

extensionHostProcess.js:105
    pulumi:pulumi:Stack test-pulumi-test running 

extensionHostProcess.js:105
    pulumi:pulumi:Stack test-pulumi-test running error: Unhandled exception: Error: Cannot find module 'prototype'

extensionHostProcess.js:105
@ updating....
extensionHostProcess.js:105
rejected promise not handled within 1 second: Error: Cannot find module 'prototype'
Require stack:
- /Applications/Visual Studio <http://Code.app/Contents/Resources/app/out/bootstrap-amd.js|Code.app/Contents/Resources/app/out/bootstrap-amd.js>
- /Applications/Visual Studio <http://Code.app/Contents/Resources/app/out/bootstrap-fork.js|Code.app/Contents/Resources/app/out/bootstrap-fork.js>
- 
extensionHostProcess.js:105
stack trace: Error: Cannot find module 'prototype'
Require stack:
- /Applications/Visual Studio <http://Code.app/Contents/Resources/app/out/bootstrap-amd.js|Code.app/Contents/Resources/app/out/bootstrap-amd.js>
- /Applications/Visual Studio <http://Code.app/Contents/Resources/app/out/bootstrap-fork.js|Code.app/Contents/Resources/app/out/bootstrap-fork.js>
- 
    at Module._resolveFilename (node:internal/modules/cjs/loader:1010:15)
    at Function.s._resolveFilename (node:electron/js2c/utility_init:2:2740)
    at Module._load (node:internal/modules/cjs/loader:858:27)
    at Function.f._load (node:electron/js2c/asar_bundle:2:13330)
    at Function.l._load (/Applications/Visual Studio <http://Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:127:28070|Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:127:28070>)
    at Function.p._load (/Applications/Visual Studio <http://Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:127:25404|Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:127:25404>)
    at Function.u._load (/Applications/Visual Studio <http://Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:91:22191|Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:91:22191>)
    at Module.require (node:internal/modules/cjs/loader:1082:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.get (/Applications/Visual Studio <http://Code.app/Contents/Resources/app/out/bootstrap-amd.js:6:87|Code.app/Contents/Resources/app/out/bootstrap-amd.js:6:87>)
    at pulumi-test/node_modules/@pulumi/runtime/closure/createClosure.ts:324:49
    at Generator.next (<anonymous>)
    at fulfilled (pulumi-test/node_modules/@pulumi/pulumi/runtime/closure/createClosure.js:18:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
It appears to be an issue when createClosure.addGlobalInfoAsync is serializing the globals and attempts to access the protocol key on a vscode global "_VSCODE_NODE_MODULES", which Proxies the get lookup to
require
Copy code
#pulumi:createClosure.js
async function addGlobalInfoAsync(key: string) {
    const globalObj = (<any>global)[key];
    const text = utils.isLegalMemberName(key) ? `global.${key}` : `global["${key}"]`;

    if (globalObj !== undefined && globalObj !== null) {
        await addEntriesAsync(globalObj, text);
        await addEntriesAsync(Object.getPrototypeOf(globalObj), `Object.getPrototypeOf(${text})`);
        await addEntriesAsync(globalObj.prototype, `${text}.prototype`);
    }
}
Copy code
#vscode:bootstram-amd.js
const nodeRequire = require;
if (globalThis._VSCODE_NODE_MODULES = new Proxy(Object.create(null), {
        get: (e, r) => nodeRequire(String(r))
    }), globalThis._VSCODE_PRODUCT_JSON = require("../product.json"), process.env.VSCODE_DEV) try {
    const e = require("../product.overrides.json");
    globalThis._VSCODE_PRODUCT_JSON = Object.assign(globalThis._VSCODE_PRODUCT_JSON, e)
} catch {}
2 Views