中止node.js中的进程

时间:2019-02-17 07:13:04

标签: node.js

当我调用process.abort()时,以下堆栈跟踪是什么意思?

Error: Command failed: node test/abort.js
 1: 0x1000621d5 node::Abort() [/usr/local/bin/node]
 2: 0x1000b8125 node::Chdir(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
 3: 0x1004880d2 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) [/usr/local/bin/node]
 4: 0x1001d89ec v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node]
 5: 0x1001d8218 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]
 6: 0xcae5e24fc7d 

是否可以中止进程而不会出错?

1 个答案:

答案 0 :(得分:3)

您通常希望执行process.exit(0)并让程序自行终止。 process.abort立即中止。有关exitabort的详细信息,请参见this SO线程