@agoric/eventual-send
Advanced tools
Comparing version 0.13.0 to 0.13.1
@@ -6,2 +6,17 @@ # Change Log | ||
## [0.13.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/eventual-send@0.13.0...@agoric/eventual-send@0.13.1) (2021-02-16) | ||
### Bug Fixes | ||
* add placeholder for top-of-turn error logging ([#2163](https://github.com/Agoric/agoric-sdk/issues/2163)) ([f0c257c](https://github.com/Agoric/agoric-sdk/commit/f0c257ceb420f1d6fb4513ff9ef8c7c773b6e333)) | ||
* Correlate sent errors with received errors ([73b9cfd](https://github.com/Agoric/agoric-sdk/commit/73b9cfd33cf7842bdc105a79592028649cb1c92a)) | ||
* review comments ([7db7e5c](https://github.com/Agoric/agoric-sdk/commit/7db7e5c4c569dfedff8d748dd58893218b0a2458)) | ||
* use assert rather than FooError constructors ([f860c5b](https://github.com/Agoric/agoric-sdk/commit/f860c5bf5add165a08cb5bd543502857c3f57998)) | ||
* **eventual-send:** test static method rejections ([f6bd055](https://github.com/Agoric/agoric-sdk/commit/f6bd055ccc897dc49ae92f452dcd5abf45bfae14)) | ||
# [0.13.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/eventual-send@0.12.0...@agoric/eventual-send@0.13.0) (2020-12-10) | ||
@@ -8,0 +23,0 @@ |
{ | ||
"name": "@agoric/eventual-send", | ||
"version": "0.13.0", | ||
"version": "0.13.1", | ||
"description": "Extend a Promise class to implement the eventual-send API", | ||
@@ -28,4 +28,4 @@ "parsers": { | ||
"devDependencies": { | ||
"@agoric/assert": "^0.2.0", | ||
"@agoric/install-ses": "^0.5.0", | ||
"@agoric/assert": "^0.2.1", | ||
"@agoric/install-ses": "^0.5.1", | ||
"ava": "^3.12.1", | ||
@@ -66,3 +66,3 @@ "esm": "^3.2.7", | ||
}, | ||
"gitHead": "f9fab94b70ed22d7fcccb261af11ed8dd6348614" | ||
"gitHead": "543364676bbfebee91366925a4f3f56989683562" | ||
} |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable */ | ||
// Type definitions for eventual-send | ||
@@ -24,3 +25,3 @@ // TODO: Add jsdocs. | ||
interface HandledPromiseConstructor extends PromiseConstructor { | ||
declare interface HandledPromiseConstructor extends PromiseConstructor { | ||
new <R>( | ||
@@ -43,4 +44,10 @@ executor: HandledExecutor<R>, | ||
export const HandledPromise: HandledPromiseConstructor; | ||
declare var HandledPromise: HandledPromiseConstructor; | ||
namespace global { | ||
declare var HandledPromise: HandledPromiseConstructor; | ||
} | ||
declare function makeHandledPromise(): HandledPromiseConstructor; | ||
/* Types for E proxy calls. */ | ||
@@ -47,0 +54,0 @@ type ESingleMethod<T> = { |
@@ -27,3 +27,3 @@ import { trackTurns } from './track-turns'; | ||
* | ||
* @returns {typeof HandledPromise} Handled promise | ||
* @returns {import('.').HandledPromiseConstructor} Handled promise | ||
*/ | ||
@@ -358,2 +358,4 @@ export function makeHandledPromise() { | ||
const ntypeof = specimen => (specimen === null ? 'null' : typeof specimen); | ||
// eslint-disable-next-line prefer-const | ||
@@ -365,5 +367,5 @@ forwardingHandler = { | ||
if (!(t instanceof Function)) { | ||
const ftype = typeof t; | ||
const ftype = ntypeof(t); | ||
throw TypeError( | ||
`Cannot invoke target as a function, the type is ${ftype}`, | ||
`Cannot invoke target as a function; typeof target is ${q(ftype)}`, | ||
); | ||
@@ -373,16 +375,16 @@ } | ||
} | ||
if (!t) { | ||
const ftype = typeof t; | ||
if (t === undefined || t === null) { | ||
const ftype = ntypeof(t); | ||
throw TypeError( | ||
`Cannot deliver ${q(method)} to target; typeof target is "${ftype}"`, | ||
`Cannot deliver ${q(method)} to target; typeof target is ${q(ftype)}`, | ||
); | ||
} | ||
if (!(method in t)) { | ||
const names = Object.getOwnPropertyNames(t).sort(); | ||
throw TypeError(`target has no method ${q(method)}, has [${names}]`); | ||
} | ||
if (!(t[method] instanceof Function)) { | ||
const ftype = typeof t[method]; | ||
const ftype = ntypeof(t[method]); | ||
if (ftype === 'undefined') { | ||
const names = Object.getOwnPropertyNames(t).sort(); | ||
throw TypeError(`target has no method ${q(method)}, has ${q(names)}`); | ||
} | ||
throw TypeError( | ||
`invoked method ${q(method)} is not a function, it is a ${ftype}`, | ||
`invoked method ${q(method)} is not a function; it is a ${q(ftype)}`, | ||
); | ||
@@ -389,0 +391,0 @@ } |
// @ts-nocheck | ||
// NOTE: We can't import these because they're not in scope before lockdown. | ||
// import { assert, details as d } from '@agoric/assert'; | ||
// import { assert, details as X } from '@agoric/assert'; | ||
@@ -17,2 +17,5 @@ // WARNING: Global Mutable State! | ||
// Turn on if you seem to be losing error logging at the top of the event loop | ||
const VERBOSE = false; | ||
/** | ||
@@ -42,2 +45,4 @@ * @typedef {((...args: any[]) => any) | void} TurnStarterFn | ||
} | ||
const { details: X } = assert; | ||
hiddenCurrentEvent += 1; | ||
@@ -48,3 +53,3 @@ const sendingError = new Error( | ||
if (hiddenPriorError !== undefined) { | ||
assert.note(sendingError, assert.details`Caused by: ${hiddenPriorError}`); | ||
assert.note(sendingError, X`Caused by: ${hiddenPriorError}`); | ||
} | ||
@@ -60,9 +65,28 @@ | ||
try { | ||
return func(...args); | ||
} catch (err) { | ||
assert.note( | ||
err, | ||
assert.details`Thrown from: ${hiddenPriorError}:${hiddenCurrentTurn}.${hiddenCurrentEvent}`, | ||
); | ||
throw err; | ||
let result; | ||
try { | ||
result = func(...args); | ||
} catch (err) { | ||
if (err instanceof Error) { | ||
assert.note( | ||
err, | ||
X`Thrown from: ${hiddenPriorError}:${hiddenCurrentTurn}.${hiddenCurrentEvent}`, | ||
); | ||
} | ||
if (VERBOSE) { | ||
console.log('THROWN to top of event loop', err); | ||
} | ||
throw err; | ||
} | ||
// Must capture this now, not when the catch triggers. | ||
const detailsNote = X`Rejection from: ${hiddenPriorError}:${hiddenCurrentTurn}.${hiddenCurrentEvent}`; | ||
Promise.resolve(result).catch(reason => { | ||
if (reason instanceof Error) { | ||
assert.note(reason, detailsNote); | ||
} | ||
if (VERBOSE) { | ||
console.log('REJECTED at top of event loop', reason); | ||
} | ||
}); | ||
return result; | ||
} finally { | ||
@@ -69,0 +93,0 @@ hiddenPriorError = undefined; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
109614
2284