Skip to content

Commit

Permalink
Set error code in Node-API functions (#16223)
Browse files Browse the repository at this point in the history
  • Loading branch information
190n authored Jan 8, 2025
1 parent 7161ded commit 72c9c2b
Show file tree
Hide file tree
Showing 7 changed files with 985 additions and 1,150 deletions.
1 change: 0 additions & 1 deletion src/bun.js/bindings/BunProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "JavaScriptCore/PutPropertySlot.h"
#include "ScriptExecutionContext.h"
#include "headers-handwritten.h"
#include "node_api.h"
#include "ZigGlobalObject.h"
#include "headers.h"
#include "JSEnvironmentVariableMap.h"
Expand Down
12 changes: 12 additions & 0 deletions src/bun.js/bindings/ZigGlobalObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class GlobalInternals;
#include "BunCommonStrings.h"
#include "BunHttp2CommonStrings.h"
#include "BunGlobalScope.h"
#include <js_native_api.h>

namespace WebCore {
class WorkerGlobalScope;
Expand Down Expand Up @@ -596,6 +597,17 @@ class GlobalObject : public Bun::GlobalScope {

bool hasOverridenModuleResolveFilenameFunction = false;

// Almost all NAPI functions should set error_code to the status they're returning right before
// they return it
napi_extended_error_info m_lastNapiErrorInfo = {
.error_message = "",
// Not currently used by Bun -- always nullptr
.engine_reserved = nullptr,
// Not currently used by Bun -- always zero
.engine_error_code = 0,
.error_code = napi_ok,
};

private:
DOMGuardedObjectSet m_guardedObjects WTF_GUARDED_BY_LOCK(m_gcLock);
WebCore::SubtleCrypto* m_subtleCrypto = nullptr;
Expand Down
Loading

0 comments on commit 72c9c2b

Please sign in to comment.