Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/rcl_subscription_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,22 @@ Napi::Value SetContentFilter(const Napi::CallbackInfo& info) {
free(argv);
}

std::string error_string = "";
if (ret != RCL_RET_OK) {
error_string = rcl_get_error_string().str;
rcl_reset_error();
}

rcl_ret_t fini_ret =
rcl_subscription_content_filter_options_fini(subscription, &options);

if (ret != RCL_RET_OK) {
std::string error_string = rcl_get_error_string().str;
rcl_reset_error();
Napi::Error::New(env, error_string).ThrowAsJavaScriptException();
return env.Undefined();
}

if (fini_ret != RCL_RET_OK) {
std::string error_string = rcl_get_error_string().str;
error_string = rcl_get_error_string().str;
rcl_reset_error();
Napi::Error::New(env, error_string).ThrowAsJavaScriptException();
return env.Undefined();
Expand Down
6 changes: 6 additions & 0 deletions test/test-subscription-content-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ describe('subscription content-filtering', function () {
const contentFilter5 = {
expression: 'data = 5',
};
// Stop spinning before changing content filter to avoid race condition
this.subscriberNode.stop();
subscription.setContentFilter(contentFilter5);
this.subscriberNode.spin();
resolve(msgCnt);
}, SUBSCRIBER_WAIT_TIME)
);
Expand Down Expand Up @@ -364,7 +367,10 @@ describe('subscription content-filtering', function () {
const p1 = new Promise((resolve) =>
setTimeout(() => {
const result = !msgCnt0 && msgCnt5 && !fail;
// Stop spinning before changing content filter to avoid race condition
this.subscriberNode.stop();
subscription.setContentFilter();
this.subscriberNode.spin();
resolve(result);
}, SUBSCRIBER_WAIT_TIME)
);
Expand Down
Loading