mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
fix bug with instanceof Promise check
This commit is contained in:
@@ -119,6 +119,8 @@ const make_patched_method = (original, name, use_context) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// IO trace replay
|
||||||
|
|
||||||
const call = cxt.io_trace[cxt.io_trace_index]
|
const call = cxt.io_trace[cxt.io_trace_index]
|
||||||
|
|
||||||
// TODO if call == null or call.type == 'resolution', then do not discard
|
// TODO if call == null or call.type == 'resolution', then do not discard
|
||||||
@@ -197,7 +199,10 @@ const make_patched_method = (original, name, use_context) => {
|
|||||||
cxt.io_trace_index++
|
cxt.io_trace_index++
|
||||||
|
|
||||||
if(call.ok) {
|
if(call.ok) {
|
||||||
if(call.value instanceof cxt.window.Promise) {
|
// Use Symbol.toStringTag for comparison because Promise may
|
||||||
|
// originate from another window (if window was reopened after record
|
||||||
|
// trace) and instanceof would not work
|
||||||
|
if(call.value?.[Symbol.toStringTag] == 'Promise') {
|
||||||
// Always make promise originate from run_window
|
// Always make promise originate from run_window
|
||||||
return new cxt.window.Promise(resolve => {
|
return new cxt.window.Promise(resolve => {
|
||||||
cxt.io_trace_resolvers.set(cxt.io_trace_index - 1, resolve)
|
cxt.io_trace_resolvers.set(cxt.io_trace_index - 1, resolve)
|
||||||
|
|||||||
Reference in New Issue
Block a user