Skip to content
Merged
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
6 changes: 5 additions & 1 deletion src/Consumer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ void MessageListenerProxy(Napi::Env env, Napi::Function jsCallback, MessageListe
Consumer *consumer = data->consumer;
delete data;

jsCallback.Call({msg, consumer->Value()});
// `consumer` might be null in certain cases, segmentation fault might happend without this null check. We
// need to handle this rare case in future.
if (consumer) {
Copy link
Contributor

@gaoran10 gaoran10 Jun 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to print some warning messages when the consumer is a null value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The initial value is null. And I found the NodeJS wrapper never logs any message. Even if you added a log here, there is still helpless to find in which scenario consumer is null here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if users lose to handle some messages when the consumer is null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the controversial point is whether should we skip the null consumer.

  • Yes: might lose messages (not sure)
  • No: fast fail

Adding logs doesn't solve anything. There is no logger in NodeJS client, printing logs to console is meaningless and helpless as I said.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need more info to reproduce the segmentation fault. But for now, a safe solution is to avoid accessing a null consumer.

jsCallback.Call({msg, consumer->Value()});
}
}

void MessageListener(pulsar_consumer_t *rawConsumer, pulsar_message_t *rawMessage, void *ctx) {
Expand Down