| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 63391e7 commit 80f86e5
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -298,8 +298,9 @@ ObjectDefineProperty(process, 'features', { | |||
| 298 | 298 | hasUncaughtExceptionCaptureCallback; | |
| 299 | 299 | } | |
| 300 | 300 | ||
| 301 | - const { emitWarning } = require('internal/process/warning'); | ||
| 301 | + const { emitWarning, emitWarningSync } = require('internal/process/warning'); | ||
| 302 | 302 | process.emitWarning = emitWarning; | |
| 303 | + internalBinding('process_methods').setEmitWarningSync(emitWarningSync); | ||
| 303 | 304 | ||
| 304 | 305 | // We initialize the tick callbacks and the timer callbacks last during | |
| 305 | 306 | // bootstrap to make sure that any operation done before this are synchronous. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -438,6 +438,7 @@ | |||
| 438 | 438 | V(performance_entry_callback, v8::Function) \ | |
| 439 | 439 | V(prepare_stack_trace_callback, v8::Function) \ | |
| 440 | 440 | V(process_object, v8::Object) \ | |
| 441 | + V(process_emit_warning_sync, v8::Function) \ | ||
| 441 | 442 | V(primordials, v8::Object) \ | |
| 442 | 443 | V(primordials_safe_map_prototype_object, v8::Object) \ | |
| 443 | 444 | V(primordials_safe_set_prototype_object, v8::Object) \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,6 +36,8 @@ template <typename... Args> | |||
| 36 | 36 | inline v8::Maybe<bool> ProcessEmitWarning(Environment* env, | |
| 37 | 37 | const char* fmt, | |
| 38 | 38 | Args&&... args); | |
| 39 | + | ||
| 40 | + v8::Maybe<bool> ProcessEmitWarningSync(Environment* env, const char* message); | ||
| 39 | 41 | v8::Maybe<bool> ProcessEmitExperimentalWarning(Environment* env, | |
| 40 | 42 | const char* warning); | |
| 41 | 43 | v8::Maybe<bool> ProcessEmitDeprecationWarning(Environment* env, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,24 @@ using v8::Object; | |||
| 18 | 18 | using v8::String; | |
| 19 | 19 | using v8::Value; | |
| 20 | 20 | ||
| 21 | + Maybe<bool> ProcessEmitWarningSync(Environment* env, const char* message) { | ||
| 22 | + Isolate* isolate = env->isolate(); | ||
| 23 | + Local<Context> context = env->context(); | ||
| 24 | + Local<String> message_string = OneByteString(isolate, message); | ||
| 25 | + | ||
| 26 | + Local<Value> argv[] = {message_string}; | ||
| 27 | + Local<Function> emit_function = env->process_emit_warning_sync(); | ||
| 28 | + // If this fails, this is called too early - before the bootstrap is even | ||
| 29 | + // finished. | ||
| 30 | + CHECK(!emit_function.IsEmpty()); | ||
| 31 | + if (emit_function.As<Function>() | ||
| 32 | + ->Call(context, v8::Undefined(isolate), arraysize(argv), argv) | ||
| 33 | + .IsEmpty()) { | ||
| 34 | + return Nothing<bool>(); | ||
| 35 | + } | ||
| 36 | + return Just(true); | ||
| 37 | + } | ||
| 38 | + | ||
| 21 | 39 | MaybeLocal<Value> ProcessEmit(Environment* env, | |
| 22 | 40 | const char* event, | |
| 23 | 41 | Local<Value> message) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,6 +41,7 @@ using v8::ArrayBuffer; | |||
| 41 | 41 | using v8::CFunction; | |
| 42 | 42 | using v8::Context; | |
| 43 | 43 | using v8::Float64Array; | |
| 44 | + using v8::Function; | ||
| 44 | 45 | using v8::FunctionCallbackInfo; | |
| 45 | 46 | using v8::HeapStatistics; | |
| 46 | 47 | using v8::Integer; | |
@@ -622,6 +623,12 @@ void BindingData::Deserialize(Local<Context> context, | |||
| 622 | 623 | CHECK_NOT_NULL(binding); | |
| 623 | 624 | } | |
| 624 | 625 | ||
| 626 | + static void SetEmitWarningSync(const FunctionCallbackInfo<Value>& args) { | ||
| 627 | + CHECK(args[0]->IsFunction()); | ||
| 628 | + Environment* env = Environment::GetCurrent(args); | ||
| 629 | + env->set_process_emit_warning_sync(args[0].As<Function>()); | ||
| 630 | + } | ||
| 631 | + | ||
| 625 | 632 | static void CreatePerIsolateProperties(IsolateData* isolate_data, | |
| 626 | 633 | Local<ObjectTemplate> target) { | |
| 627 | 634 | Isolate* isolate = isolate_data->isolate(); | |
@@ -655,6 +662,8 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data, | |||
| 655 | 662 | SetMethod(isolate, target, "patchProcessObject", PatchProcessObject); | |
| 656 | 663 | ||
| 657 | 664 | SetMethod(isolate, target, "loadEnvFile", LoadEnvFile); | |
| 665 | + | ||
| 666 | + SetMethod(isolate, target, "setEmitWarningSync", SetEmitWarningSync); | ||
| 658 | 667 | } | |
| 659 | 668 | ||
| 660 | 669 | static void CreatePerContextProperties(Local<Object> target, | |
@@ -695,6 +704,8 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) { | |||
| 695 | 704 | registry->Register(PatchProcessObject); | |
| 696 | 705 | ||
| 697 | 706 | registry->Register(LoadEnvFile); | |
| 707 | + | ||
| 708 | + registry->Register(SetEmitWarningSync); | ||
| 698 | 709 | } | |
| 699 | 710 | ||
| 700 | 711 | } // namespace process | |
| Back | FazBrowse Home | New Git URL |
0 commit comments