@agoric/eventual-send
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -6,2 +6,14 @@ # Change Log | ||
## [0.9.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/eventual-send@0.9.0...@agoric/eventual-send@0.9.1) (2020-05-10) | ||
### Bug Fixes | ||
* be lazy in choosing which handler to use ([904b610](https://github.com/Agoric/agoric-sdk/commit/904b610685a50ba32dc0712e62f4c902f61e437a)) | ||
* be sure to propagate handler failures ([2b931fc](https://github.com/Agoric/agoric-sdk/commit/2b931fcb60afcb24fd7c331eadd12dbfc4592e85)) | ||
# [0.9.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/eventual-send@0.8.0...@agoric/eventual-send@0.9.0) (2020-05-04) | ||
@@ -8,0 +20,0 @@ |
@@ -508,10 +508,12 @@ 'use strict'; | ||
ensureMaps(); | ||
p = shorten(p); | ||
const unsettledHandler = promiseToUnsettledHandler.get(p); | ||
let executor; | ||
if (unsettledHandler && typeof unsettledHandler[operation] === 'function') { | ||
executor = (resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve() | ||
.then(() => | ||
const returnedP = new HandledPromise((resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve() | ||
.then(() => { | ||
p = shorten(p); | ||
const unsettledHandler = promiseToUnsettledHandler.get(p); | ||
if ( | ||
unsettledHandler && | ||
typeof unsettledHandler[operation] === 'function' | ||
) { | ||
// and resolve to the answer from the specific unsettled handler, | ||
@@ -521,26 +523,25 @@ // opArgs are something like [prop] or [method, args], | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(unsettledHandler[operation](p, ...opArgs, returnedP)), | ||
) | ||
.catch(reject); | ||
}; | ||
} else { | ||
executor = (resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve(p) | ||
.then(o => { | ||
// We now have the naked object, | ||
if (typeof forwardingHandler[operation] !== 'function') { | ||
throw TypeError( | ||
`forwardingHandler.${operation} is not a function`, | ||
); | ||
} | ||
// and resolve to the forwardingHandler's operation. | ||
// opArgs are something like [prop] or [method, args], | ||
// so we don't risk the user's args leaking into this expansion. | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(unsettledHandler[operation](p, ...opArgs, returnedP)); | ||
} else if (typeof forwardingHandler[operation] !== 'function') { | ||
throw TypeError(`forwardingHandler.${operation} is not a function`); | ||
} else if (Object(p) !== p || !('then' in p)) { | ||
// Not a Thenable, so use it. | ||
resolve(forwardingHandler[operation](p, ...opArgs, returnedP)); | ||
} else if (promiseToPresence.has(p)) { | ||
// We have the object synchronously, so resolve with it. | ||
const o = promiseToPresence.get(p); | ||
resolve(forwardingHandler[operation](o, ...opArgs, returnedP)); | ||
}) | ||
.catch(reject); | ||
}; | ||
} | ||
} else { | ||
p.then(o => { | ||
// We now have the naked object, | ||
// so resolve to the forwardingHandler's operation. | ||
// opArgs are something like [prop] or [method, args], | ||
// so we don't risk the user's args leaking into this expansion. | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(forwardingHandler[operation](o, ...opArgs, returnedP)); | ||
}).catch(reject); | ||
} | ||
}) | ||
.catch(reject); | ||
}); | ||
@@ -550,3 +551,2 @@ // We return a handled promise with the default unsettled handler. | ||
// pipelining. | ||
const returnedP = new HandledPromise(executor); | ||
return returnedP; | ||
@@ -553,0 +553,0 @@ }; |
@@ -502,10 +502,12 @@ import harden from '@agoric/harden'; | ||
ensureMaps(); | ||
p = shorten(p); | ||
const unsettledHandler = promiseToUnsettledHandler.get(p); | ||
let executor; | ||
if (unsettledHandler && typeof unsettledHandler[operation] === 'function') { | ||
executor = (resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve() | ||
.then(() => | ||
const returnedP = new HandledPromise((resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve() | ||
.then(() => { | ||
p = shorten(p); | ||
const unsettledHandler = promiseToUnsettledHandler.get(p); | ||
if ( | ||
unsettledHandler && | ||
typeof unsettledHandler[operation] === 'function' | ||
) { | ||
// and resolve to the answer from the specific unsettled handler, | ||
@@ -515,26 +517,25 @@ // opArgs are something like [prop] or [method, args], | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(unsettledHandler[operation](p, ...opArgs, returnedP)), | ||
) | ||
.catch(reject); | ||
}; | ||
} else { | ||
executor = (resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve(p) | ||
.then(o => { | ||
// We now have the naked object, | ||
if (typeof forwardingHandler[operation] !== 'function') { | ||
throw TypeError( | ||
`forwardingHandler.${operation} is not a function`, | ||
); | ||
} | ||
// and resolve to the forwardingHandler's operation. | ||
// opArgs are something like [prop] or [method, args], | ||
// so we don't risk the user's args leaking into this expansion. | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(unsettledHandler[operation](p, ...opArgs, returnedP)); | ||
} else if (typeof forwardingHandler[operation] !== 'function') { | ||
throw TypeError(`forwardingHandler.${operation} is not a function`); | ||
} else if (Object(p) !== p || !('then' in p)) { | ||
// Not a Thenable, so use it. | ||
resolve(forwardingHandler[operation](p, ...opArgs, returnedP)); | ||
} else if (promiseToPresence.has(p)) { | ||
// We have the object synchronously, so resolve with it. | ||
const o = promiseToPresence.get(p); | ||
resolve(forwardingHandler[operation](o, ...opArgs, returnedP)); | ||
}) | ||
.catch(reject); | ||
}; | ||
} | ||
} else { | ||
p.then(o => { | ||
// We now have the naked object, | ||
// so resolve to the forwardingHandler's operation. | ||
// opArgs are something like [prop] or [method, args], | ||
// so we don't risk the user's args leaking into this expansion. | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(forwardingHandler[operation](o, ...opArgs, returnedP)); | ||
}).catch(reject); | ||
} | ||
}) | ||
.catch(reject); | ||
}); | ||
@@ -544,3 +545,2 @@ // We return a handled promise with the default unsettled handler. | ||
// pipelining. | ||
const returnedP = new HandledPromise(executor); | ||
return returnedP; | ||
@@ -547,0 +547,0 @@ }; |
@@ -508,10 +508,12 @@ (function (global, factory) { | ||
ensureMaps(); | ||
p = shorten(p); | ||
const unsettledHandler = promiseToUnsettledHandler.get(p); | ||
let executor; | ||
if (unsettledHandler && typeof unsettledHandler[operation] === 'function') { | ||
executor = (resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve() | ||
.then(() => | ||
const returnedP = new HandledPromise((resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve() | ||
.then(() => { | ||
p = shorten(p); | ||
const unsettledHandler = promiseToUnsettledHandler.get(p); | ||
if ( | ||
unsettledHandler && | ||
typeof unsettledHandler[operation] === 'function' | ||
) { | ||
// and resolve to the answer from the specific unsettled handler, | ||
@@ -521,26 +523,25 @@ // opArgs are something like [prop] or [method, args], | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(unsettledHandler[operation](p, ...opArgs, returnedP)), | ||
) | ||
.catch(reject); | ||
}; | ||
} else { | ||
executor = (resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve(p) | ||
.then(o => { | ||
// We now have the naked object, | ||
if (typeof forwardingHandler[operation] !== 'function') { | ||
throw TypeError( | ||
`forwardingHandler.${operation} is not a function`, | ||
); | ||
} | ||
// and resolve to the forwardingHandler's operation. | ||
// opArgs are something like [prop] or [method, args], | ||
// so we don't risk the user's args leaking into this expansion. | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(unsettledHandler[operation](p, ...opArgs, returnedP)); | ||
} else if (typeof forwardingHandler[operation] !== 'function') { | ||
throw TypeError(`forwardingHandler.${operation} is not a function`); | ||
} else if (Object(p) !== p || !('then' in p)) { | ||
// Not a Thenable, so use it. | ||
resolve(forwardingHandler[operation](p, ...opArgs, returnedP)); | ||
} else if (promiseToPresence.has(p)) { | ||
// We have the object synchronously, so resolve with it. | ||
const o = promiseToPresence.get(p); | ||
resolve(forwardingHandler[operation](o, ...opArgs, returnedP)); | ||
}) | ||
.catch(reject); | ||
}; | ||
} | ||
} else { | ||
p.then(o => { | ||
// We now have the naked object, | ||
// so resolve to the forwardingHandler's operation. | ||
// opArgs are something like [prop] or [method, args], | ||
// so we don't risk the user's args leaking into this expansion. | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(forwardingHandler[operation](o, ...opArgs, returnedP)); | ||
}).catch(reject); | ||
} | ||
}) | ||
.catch(reject); | ||
}); | ||
@@ -550,3 +551,2 @@ // We return a handled promise with the default unsettled handler. | ||
// pipelining. | ||
const returnedP = new HandledPromise(executor); | ||
return returnedP; | ||
@@ -553,0 +553,0 @@ }; |
{ | ||
"name": "@agoric/eventual-send", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "Extend a Promise class to implement the eventual-send API", | ||
@@ -48,3 +48,3 @@ "main": "dist/eventual-send.cjs.js", | ||
}, | ||
"gitHead": "534d1a65d79f9dd176cc670f374c9de2cd081a7e" | ||
"gitHead": "41e9cd4b0475b0b0cc461e9c54c5dbec82994e3c" | ||
} |
@@ -433,10 +433,12 @@ /* global HandledPromise */ | ||
ensureMaps(); | ||
p = shorten(p); | ||
const unsettledHandler = promiseToUnsettledHandler.get(p); | ||
let executor; | ||
if (unsettledHandler && typeof unsettledHandler[operation] === 'function') { | ||
executor = (resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve() | ||
.then(() => | ||
const returnedP = new HandledPromise((resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve() | ||
.then(() => { | ||
p = shorten(p); | ||
const unsettledHandler = promiseToUnsettledHandler.get(p); | ||
if ( | ||
unsettledHandler && | ||
typeof unsettledHandler[operation] === 'function' | ||
) { | ||
// and resolve to the answer from the specific unsettled handler, | ||
@@ -446,26 +448,25 @@ // opArgs are something like [prop] or [method, args], | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(unsettledHandler[operation](p, ...opArgs, returnedP)), | ||
) | ||
.catch(reject); | ||
}; | ||
} else { | ||
executor = (resolve, reject) => { | ||
// We run in a future turn to prevent synchronous attacks, | ||
HandledPromise.resolve(p) | ||
.then(o => { | ||
// We now have the naked object, | ||
if (typeof forwardingHandler[operation] !== 'function') { | ||
throw TypeError( | ||
`forwardingHandler.${operation} is not a function`, | ||
); | ||
} | ||
// and resolve to the forwardingHandler's operation. | ||
// opArgs are something like [prop] or [method, args], | ||
// so we don't risk the user's args leaking into this expansion. | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(unsettledHandler[operation](p, ...opArgs, returnedP)); | ||
} else if (typeof forwardingHandler[operation] !== 'function') { | ||
throw TypeError(`forwardingHandler.${operation} is not a function`); | ||
} else if (Object(p) !== p || !('then' in p)) { | ||
// Not a Thenable, so use it. | ||
resolve(forwardingHandler[operation](p, ...opArgs, returnedP)); | ||
} else if (promiseToPresence.has(p)) { | ||
// We have the object synchronously, so resolve with it. | ||
const o = promiseToPresence.get(p); | ||
resolve(forwardingHandler[operation](o, ...opArgs, returnedP)); | ||
}) | ||
.catch(reject); | ||
}; | ||
} | ||
} else { | ||
p.then(o => { | ||
// We now have the naked object, | ||
// so resolve to the forwardingHandler's operation. | ||
// opArgs are something like [prop] or [method, args], | ||
// so we don't risk the user's args leaking into this expansion. | ||
// eslint-disable-next-line no-use-before-define | ||
resolve(forwardingHandler[operation](o, ...opArgs, returnedP)); | ||
}).catch(reject); | ||
} | ||
}) | ||
.catch(reject); | ||
}); | ||
@@ -475,3 +476,2 @@ // We return a handled promise with the default unsettled handler. | ||
// pipelining. | ||
const returnedP = new HandledPromise(executor); | ||
return returnedP; | ||
@@ -478,0 +478,0 @@ }; |
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
95196