@pulumi/pulumi
Advanced tools
Comparing version 3.121.1-alpha.x4a12902 to 3.121.1-alpha.x4ebccb8
{ | ||
"name": "@pulumi/pulumi", | ||
"version": "3.121.1-alpha.x4a12902", | ||
"version": "3.121.1-alpha.x4ebccb8", | ||
"description": "Pulumi's Node.js SDK", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -49,7 +49,19 @@ "use strict"; | ||
constructor(engineAddr, provider, uncaughtErrors) { | ||
/** Queue of construct calls. */ | ||
this.constructCallQueue = Promise.resolve(); | ||
this._callbacks = new Map(); | ||
this.engineAddr = engineAddr; | ||
this.provider = provider; | ||
this.uncaughtErrors = uncaughtErrors; | ||
// When we catch an uncaught error, we need to respond to the inflight call/construct gRPC requests | ||
// with the error to avoid a hang. | ||
const uncaughtHandler = (err) => { | ||
if (!this.uncaughtErrors.has(err)) { | ||
this.uncaughtErrors.add(err); | ||
} | ||
// terminate the outstanding gRPC requests. | ||
this._callbacks.forEach((callback) => callback(err, undefined)); | ||
}; | ||
process.on("uncaughtException", uncaughtHandler); | ||
// @ts-ignore 'unhandledRejection' will almost always invoke uncaughtHandler with an Error. so | ||
// just suppress the TS strictness here. | ||
process.on("unhandledRejection", uncaughtHandler); | ||
} | ||
@@ -260,30 +272,4 @@ // Misc. methods | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// Serialize invocations of `construct` and `call` so that each call runs one after another, avoiding concurrent | ||
// runs. We do this because `construct` and `call` modify global state to reset the SDK's runtime options. | ||
// This is a short-term workaround to provide correctness, but likely isn't sustainable long-term due to the | ||
// limits it places on parallelism. We will likely want to investigate if it's possible to run each invocation | ||
// in its own context, possibly using Node's `createContext` API to avoid modifying global state: | ||
// https://nodejs.org/api/vm.html#vm_vm_createcontext_contextobject_options | ||
const res = this.constructCallQueue.then(() => this.constructImpl(call, callback)); | ||
/* eslint-disable no-empty,no-empty-function,@typescript-eslint/no-empty-function */ | ||
this.constructCallQueue = res.catch(() => { }); | ||
return res; | ||
}); | ||
} | ||
constructImpl(call, callback) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// given that construct calls are serialized, we can attach an uncaught handler to pick up exceptions | ||
// in underlying user code. When we catch the error, we need to respond to the gRPC request with the error | ||
// to avoid a hang. | ||
const uncaughtHandler = (err) => { | ||
if (!this.uncaughtErrors.has(err)) { | ||
this.uncaughtErrors.add(err); | ||
} | ||
// bubble the uncaught error in the user code back and terminate the outstanding gRPC request. | ||
callback(err, undefined); | ||
}; | ||
process.on("uncaughtException", uncaughtHandler); | ||
// @ts-ignore 'unhandledRejection' will almost always invoke uncaughtHandler with an Error. so | ||
// just suppress the TS strictness here. | ||
process.on("unhandledRejection", uncaughtHandler); | ||
const callbackId = Symbol("id"); | ||
this._callbacks.set(callbackId, callback); | ||
try { | ||
@@ -338,5 +324,4 @@ const req = call.request; | ||
finally { | ||
// remove these uncaught handlers that are specific to this gRPC callback context | ||
process.off("uncaughtException", uncaughtHandler); | ||
process.off("unhandledRejection", uncaughtHandler); | ||
// remove the gRPC callback context from the map of in-flight callbacks | ||
this._callbacks.delete(callbackId); | ||
} | ||
@@ -347,30 +332,4 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// Serialize invocations of `construct` and `call` so that each call runs one after another, avoiding concurrent | ||
// runs. We do this because `construct` and `call` modify global state to reset the SDK's runtime options. | ||
// This is a short-term workaround to provide correctness, but likely isn't sustainable long-term due to the | ||
// limits it places on parallelism. We will likely want to investigate if it's possible to run each invocation | ||
// in its own context, possibly using Node's `createContext` API to avoid modifying global state: | ||
// https://nodejs.org/api/vm.html#vm_vm_createcontext_contextobject_options | ||
const res = this.constructCallQueue.then(() => this.callImpl(call, callback)); | ||
/* eslint-disable no-empty, no-empty-function, @typescript-eslint/no-empty-function */ | ||
this.constructCallQueue = res.catch(() => { }); | ||
return res; | ||
}); | ||
} | ||
callImpl(call, callback) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// given that call calls are serialized, we can attach an uncaught handler to pick up exceptions | ||
// in underlying user code. When we catch the error, we need to respond to the gRPC request with the error | ||
// to avoid a hang. | ||
const uncaughtHandler = (err) => { | ||
if (!this.uncaughtErrors.has(err)) { | ||
this.uncaughtErrors.add(err); | ||
} | ||
// bubble the uncaught error in the user code back and terminate the outstanding gRPC request. | ||
callback(err, undefined); | ||
}; | ||
process.on("uncaughtException", uncaughtHandler); | ||
// @ts-ignore 'unhandledRejection' will almost always invoke uncaughtHandler with an Error. so | ||
// just suppress the TS strictness here. | ||
process.on("unhandledRejection", uncaughtHandler); | ||
const callbackId = Symbol("id"); | ||
this._callbacks.set(callbackId, callback); | ||
try { | ||
@@ -415,5 +374,4 @@ const req = call.request; | ||
finally { | ||
// remove these uncaught handlers that are specific to this gRPC callback context | ||
process.off("uncaughtException", uncaughtHandler); | ||
process.off("unhandledRejection", uncaughtHandler); | ||
// remove the gRPC callback context from the map of in-flight callbacks | ||
this._callbacks.delete(callbackId); | ||
} | ||
@@ -420,0 +378,0 @@ }); |
@@ -16,3 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = "3.121.1-alpha.x4a12902"; | ||
exports.version = "3.121.1-alpha.x4ebccb8"; | ||
//# sourceMappingURL=version.js.map |
Sorry, the diff of this file is not supported yet
14575020
129519