edge-runtime
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -25,16 +25,22 @@ "use strict"; | ||
}); | ||
defineHandlerProps({ | ||
object: this, | ||
setterName: '__onUnhandledRejectionHandler', | ||
setter: (handlers) => (unhandledRejectionHandlers = handlers), | ||
getterName: '__rejectionHandlers', | ||
getter: () => unhandledRejectionHandlers, | ||
Object.defineProperty(this.context, '__onUnhandledRejectionHandlers', { | ||
set: registerUnhandledRejectionHandlers, | ||
configurable: false, | ||
enumerable: false, | ||
}); | ||
defineHandlerProps({ | ||
object: this, | ||
setterName: '__onErrorHandler', | ||
setter: (handlers) => (uncaughtExceptionHandlers = handlers), | ||
getterName: '__errorHandlers', | ||
getter: () => uncaughtExceptionHandlers, | ||
Object.defineProperty(this, '__rejectionHandlers', { | ||
get: () => unhandledRejectionHandlers, | ||
configurable: false, | ||
enumerable: false, | ||
}); | ||
Object.defineProperty(this.context, '__onErrorHandlers', { | ||
set: registerUncaughtExceptionHandlers, | ||
configurable: false, | ||
enumerable: false, | ||
}); | ||
Object.defineProperty(this, '__errorHandlers', { | ||
get: () => uncaughtExceptionHandlers, | ||
configurable: false, | ||
enumerable: false, | ||
}); | ||
this.evaluate(getDefineEventListenersCode()); | ||
@@ -49,11 +55,22 @@ this.dispatchFetch = this.evaluate(getDispatchFetchCode()); | ||
/** | ||
* Define system-level handlers to make sure that we report to the user | ||
* Register system-level handlers to make sure that we report to the user | ||
* whenever there is an unhandled rejection or exception before the process crashes. | ||
* Do it on demand so we don't swallow rejections/errors for no reason. | ||
*/ | ||
process.on('unhandledRejection', function invokeRejectionHandlers(reason, promise) { | ||
unhandledRejectionHandlers === null || unhandledRejectionHandlers === void 0 ? void 0 : unhandledRejectionHandlers.forEach((handler) => handler({ reason, promise })); | ||
}); | ||
process.on('uncaughtException', function invokeErrorHandlers(error) { | ||
uncaughtExceptionHandlers === null || uncaughtExceptionHandlers === void 0 ? void 0 : uncaughtExceptionHandlers.forEach((handler) => handler(error)); | ||
}); | ||
function registerUnhandledRejectionHandlers(handlers) { | ||
if (!unhandledRejectionHandlers) { | ||
process.on('unhandledRejection', function invokeRejectionHandlers(reason, promise) { | ||
unhandledRejectionHandlers.forEach((handler) => handler({ reason, promise })); | ||
}); | ||
} | ||
unhandledRejectionHandlers = handlers; | ||
} | ||
function registerUncaughtExceptionHandlers(handlers) { | ||
if (!uncaughtExceptionHandlers) { | ||
process.on('uncaughtException', function invokeErrorHandlers(error) { | ||
uncaughtExceptionHandlers.forEach((handler) => handler(error)); | ||
}); | ||
} | ||
uncaughtExceptionHandlers = handlers; | ||
} | ||
/** | ||
@@ -77,5 +94,5 @@ * Generates polyfills for addEventListener and removeEventListener. It keeps | ||
if (eventType === 'unhandledrejection') { | ||
self.__onUnhandledRejectionHandler = self.__listeners[eventType]; | ||
self.__onUnhandledRejectionHandlers = self.__listeners[eventType]; | ||
} else if (eventType === 'error') { | ||
self.__onErrorHandler = self.__listeners[eventType]; | ||
self.__onErrorHandlers = self.__listeners[eventType]; | ||
} | ||
@@ -154,18 +171,2 @@ } | ||
} | ||
/** | ||
* Defines a readable property on the VM and the corresponding writable property | ||
* on the VM's context. These properties are not enumerable nor updatable. | ||
*/ | ||
function defineHandlerProps({ object: instance, setterName, setter: setter, getterName, getter, }) { | ||
Object.defineProperty(instance.context, setterName, { | ||
set: setter, | ||
configurable: false, | ||
enumerable: false, | ||
}); | ||
Object.defineProperty(instance, getterName, { | ||
get: getter, | ||
configurable: false, | ||
enumerable: false, | ||
}); | ||
} | ||
//# sourceMappingURL=edge-runtime.js.map |
/// <reference types="node" /> | ||
import type { IncomingMessage } from 'http'; | ||
declare type BodyStream = ReadableStream<Uint8Array>; | ||
type BodyStream = ReadableStream<Uint8Array>; | ||
/** | ||
@@ -5,0 +5,0 @@ * An interface that encapsulates body stream cloning |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://edge-runtime.vercel.app/packages/runtime", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"main": "dist/index.js", | ||
@@ -21,8 +21,11 @@ "bin": { | ||
"edge", | ||
"edge-runtime", | ||
"functions", | ||
"runtime" | ||
"runtime", | ||
"standard", | ||
"web" | ||
], | ||
"dependencies": { | ||
"@edge-runtime/format": "1.1.0", | ||
"@edge-runtime/vm": "2.0.2", | ||
"@edge-runtime/format": "2.0.0", | ||
"@edge-runtime/vm": "2.0.3", | ||
"exit-hook": "2.2.1", | ||
@@ -40,2 +43,5 @@ "http-status": "1.5.3", | ||
}, | ||
"engines": { | ||
"node": ">=14" | ||
}, | ||
"files": [ | ||
@@ -42,0 +48,0 @@ "dist" |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
775
5
87269
+ Added@edge-runtime/format@2.0.0(transitive)
+ Added@edge-runtime/primitives@2.0.3(transitive)
+ Added@edge-runtime/vm@2.0.3(transitive)
- Removed@edge-runtime/format@1.1.0(transitive)
- Removed@edge-runtime/primitives@2.0.2(transitive)
- Removed@edge-runtime/vm@2.0.2(transitive)
Updated@edge-runtime/format@2.0.0
Updated@edge-runtime/vm@2.0.3