Skip to content

Commit 79b1bf5

Browse files
addaleaxtargos
authored andcommitted
test: use assert() in N-API async test
The `Execute()` callback is not allowed to call into JS, so we should use `assert()` instead of potentially throwing JS errors. PR-URL: #28423 Fixes: nodejs/help#1998 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 14f6cee commit 79b1bf5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

test/node-api/test_async/test_async.cc

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <assert.h>
12
#include <stdio.h>
23
#include <node_api.h>
34
#include "../../js-native-api/common.h"
@@ -29,10 +30,7 @@ void Execute(napi_env env, void* data) {
2930
#endif
3031
carrier* c = static_cast<carrier*>(data);
3132

32-
if (c != &the_carrier) {
33-
napi_throw_type_error(env, nullptr, "Wrong data parameter to Execute.");
34-
return;
35-
}
33+
assert(c == &the_carrier);
3634

3735
c->_output = c->_input * 2;
3836
}

0 commit comments

Comments
 (0)