From 9c60caeb33daa752119d355fc20251f1846393ec Mon Sep 17 00:00:00 2001 From: Domiii Date: Tue, 11 Jan 2022 21:53:14 +0800 Subject: [PATCH] fixed `react` (and several other callback patching-related problems) #640 --- dbux-runtime/src/async/CallbackPatcher.js | 18 +++++++++--------- .../__samplesInput__/patching/callbacks0.js | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dbux-runtime/src/async/CallbackPatcher.js b/dbux-runtime/src/async/CallbackPatcher.js index 4a252ddb8..11a1c9b27 100644 --- a/dbux-runtime/src/async/CallbackPatcher.js +++ b/dbux-runtime/src/async/CallbackPatcher.js @@ -115,15 +115,15 @@ export default class CallbackPatcher { return originalCallback; } - // let f = getPatchedFunctionOrNull(originalFunction); - // if (!f) { - // const calleePatcher = this.defaultCalleePatcher; - - // f = monkeyPatchFunctionOverride( - // originalFunction, - // calleePatcher.bind(this, callId) - // ); - // } + let f = getPatchedCallback(originalCallback); + if (f) { + return f; + // const calleePatcher = this.defaultCalleePatcher; + // f = monkeyPatchFunctionOverride( + // originalFunction, + // calleePatcher.bind(this, callId) + // ); + } // const self = this; // NOTE: `this` will be the callback's `this` diff --git a/samples/__samplesInput__/patching/callbacks0.js b/samples/__samplesInput__/patching/callbacks0.js index 575610cea..283285a61 100644 --- a/samples/__samplesInput__/patching/callbacks0.js +++ b/samples/__samplesInput__/patching/callbacks0.js @@ -38,6 +38,7 @@ function nativeCallCompare(cb) { * and many other callback management mechanisms cannot work correctly. */ nativeCallStore(cb); + debugger; nativeCallCompare(cb); // TODO: more testing here, with checks for multi-patching