arthurhsu / lovefield-ts

Lovefield TypeScript port: successor of google/lovefield
Apache License 2.0
47 stars 3 forks source link

EndToEndTransactionTest#attach_Error_Rollback has uncaught promise rejection #12

Closed arthurhsu closed 6 years ago

arthurhsu commented 6 years ago

On both Chrome and NodeJS mocha. The code actually has proper try-catch, however the rejected promise is still deemed as unhandled.

The original code uses thenCatch(), which is not provided in ES6. Either async function or plain Promise still result in unhandled promise rejection, not sure if that's a TypeScript problem or not.

freshp86 commented 6 years ago

FYI goog.Promise#thenCatch() exists now as Promise#finally(), see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally.

arthurhsu commented 6 years ago

Found the root cause: https://github.com/google/lovefield/blob/master/lib/proc/transaction_task.js#L148

Original code uses CancellationError, which has a side effect in Closure that can nicely cancel the promise. This is not provided by native Promise that used in the Typescript port.

Current implementation uses https://github.com/google/lovefield/blob/master/lib/proc/transaction_task.js#L148

which will do exactly the opposite as said in its comment above. Can't really blame freshp86@ because when he wrote that code, Promise.cancel is still an active proposal and not dead yet (and it's freaking dead now so we need to think another way to overcome).