| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2ce6e70 commit 4018c8d
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -326,14 +326,10 @@ function promiseInitHookWithDestroyTracking(promise, parent) { | |||
| 326 | 326 | destroyTracking(promise, parent); | |
| 327 | 327 | } | |
| 328 | 328 | ||
| 329 | - const destroyedSymbol = Symbol('destroyed'); | ||
| 330 | - | ||
| 331 | 329 | function destroyTracking(promise, parent) { | |
| 332 | 330 | trackPromise(promise, parent); | |
| 333 | 331 | const asyncId = promise[async_id_symbol]; | |
| 334 | - const destroyed = { destroyed: false }; | ||
| 335 | - promise[destroyedSymbol] = destroyed; | ||
| 336 | - registerDestroyHook(promise, asyncId, destroyed); | ||
| 332 | + registerDestroyHook(promise, asyncId); | ||
| 337 | 333 | } | |
| 338 | 334 | ||
| 339 | 335 | function promiseBeforeHook(promise) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -217,12 +217,13 @@ void AsyncWrap::WeakCallback(const WeakCallbackInfo<DestroyParam>& info) { | |||
| 217 | 217 | ||
| 218 | 218 | p->env->RemoveCleanupHook(DestroyParamCleanupHook, p.get()); | |
| 219 | 219 | ||
| 220 | - if (!prop_bag->Get(p->env->context(), p->env->destroyed_string()) | ||
| 220 | + if (!prop_bag.IsEmpty() && | ||
| 221 | + !prop_bag->Get(p->env->context(), p->env->destroyed_string()) | ||
| 221 | 222 | .ToLocal(&val)) { | |
| 222 | 223 | return; | |
| 223 | 224 | } | |
| 224 | 225 | ||
| 225 | - if (val->IsFalse()) { | ||
| 226 | + if (val.IsEmpty() || val->IsFalse()) { | ||
| 226 | 227 | AsyncWrap::EmitDestroy(p->env, p->asyncId); | |
| 227 | 228 | } | |
| 228 | 229 | // unique_ptr goes out of scope here and pointer is deleted. | |
@@ -232,14 +233,16 @@ void AsyncWrap::WeakCallback(const WeakCallbackInfo<DestroyParam>& info) { | |||
| 232 | 233 | static void RegisterDestroyHook(const FunctionCallbackInfo<Value>& args) { | |
| 233 | 234 | CHECK(args[0]->IsObject()); | |
| 234 | 235 | CHECK(args[1]->IsNumber()); | |
| 235 | - CHECK(args[2]->IsObject()); | ||
| 236 | + CHECK(args.Length() == 2 || args[2]->IsObject()); | ||
| 236 | 237 | ||
| 237 | 238 | Isolate* isolate = args.GetIsolate(); | |
| 238 | 239 | DestroyParam* p = new DestroyParam(); | |
| 239 | 240 | p->asyncId = args[1].As<Number>()->Value(); | |
| 240 | 241 | p->env = Environment::GetCurrent(args); | |
| 241 | 242 | p->target.Reset(isolate, args[0].As<Object>()); | |
| 242 | - p->propBag.Reset(isolate, args[2].As<Object>()); | ||
| 243 | + if (args.Length() > 2) { | ||
| 244 | + p->propBag.Reset(isolate, args[2].As<Object>()); | ||
| 245 | + } | ||
| 243 | 246 | p->target.SetWeak(p, AsyncWrap::WeakCallback, WeakCallbackType::kParameter); | |
| 244 | 247 | p->env->AddCleanupHook(DestroyParamCleanupHook, p); | |
| 245 | 248 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -107,7 +107,7 @@ declare function InternalBinding(binding: 'async_wrap'): { | |||
| 107 | 107 | promiseAfterHook: InternalAsyncWrapBinding.PromiseHook | undefined, | |
| 108 | 108 | promiseResolveHook: InternalAsyncWrapBinding.PromiseHook | undefined | |
| 109 | 109 | ): void; | |
| 110 | - registerDestroyHook(promise: Promise<unknown>, asyncId: number, destroyed: { destroyed: boolean }): void; | ||
| 110 | + registerDestroyHook(resource: object, asyncId: number, destroyed?: { destroyed: boolean }): void; | ||
| 111 | 111 | async_hook_fields: Uint32Array; | |
| 112 | 112 | async_id_fields: Float64Array; | |
| 113 | 113 | async_ids_stack: Float64Array; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments