Skip to content

Commit a3633c6

Browse files
committed
Fix internal when calling connection.subscribe with the same name twice (Issue #1718)
1 parent 4543780 commit a3633c6

File tree

7 files changed

+743
-431
lines changed

7 files changed

+743
-431
lines changed

Diff for: doc/src/release_notes.rst

+8-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Thin Mode Changes
4040

4141
#) Added connection optimization feature which uses
4242
Server Name Indication (SNI) extension of the TLS protocol.
43-
43+
4444
#) Added support for setting the :attr:`~oracledb.edition` when connecting to
4545
the database.
4646

@@ -53,6 +53,13 @@ Thin Mode Changes
5353
Thick Mode Changes
5454
++++++++++++++++++
5555

56+
#) Fixed internal error that occurs while running ``connection.subscribe()``
57+
with same name for second time.
58+
See `Issue #1718 <https://github.com/oracle/node-oracledb/issues/1718>`__.
59+
60+
#) Fixed internal error that occurs while running ``connection.subscribe()`` with
61+
sql reading from non-existent tables.
62+
5663
#) Internal error handling improvements.
5764

5865
node-oracledb `v6.7.1 <https://github.com/oracle/node-oracledb/compare/v6.7.0...v6.7.1>`__ (23 Dec 2024)

Diff for: src/njsConnection.c

+2
Original file line numberDiff line numberDiff line change
@@ -2359,6 +2359,8 @@ NJS_NAPI_METHOD_IMPL_ASYNC(njsConnection_subscribe, 2, NULL)
23592359
if (valueType == napi_external) {
23602360
NJS_CHECK_NAPI(env, napi_get_value_external(env, args[0],
23612361
(void**) &baton->subscription))
2362+
NJS_CHECK_NAPI(env, napi_create_reference(env, args[0], 1,
2363+
&baton->jsSubscriptionRef))
23622364
} else {
23632365
if (!njsSubscription_new(baton, env))
23642366
return false;

Diff for: src/njsSubscription.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2025, Oracle and/or its affiliates.
22

33
//-----------------------------------------------------------------------------
44
//
@@ -268,7 +268,8 @@ static bool njsSubscription_createMessageTable(napi_env env,
268268
void njsSubscription_eventHandler(njsSubscription *subscr,
269269
dpiSubscrMessage *incomingMessage)
270270
{
271-
if (subscr->handle) {
271+
// handle is valid and listening notifications is enabled.
272+
if (subscr->handle && subscr->notifications) {
272273
uv_mutex_lock(&subscr->mutex);
273274
uv_barrier_init(&subscr->barrier, 2);
274275
subscr->message = incomingMessage;
@@ -428,7 +429,6 @@ bool njsSubscription_startNotifications(njsSubscription *subscr,
428429
if (!subscr->notifications) {
429430

430431
// keep the name on the subscription
431-
subscr->notifications = true;
432432
baton->name = NULL;
433433
baton->nameLength = 0;
434434

@@ -438,6 +438,7 @@ bool njsSubscription_startNotifications(njsSubscription *subscr,
438438
uv_async_init(loop, &subscr->async,
439439
njsSubscription_processNotification);
440440
subscr->async.data = subscr;
441+
subscr->notifications = true;
441442

442443
}
443444

0 commit comments

Comments
 (0)