Skip to content

Commit 1f30018

Browse files
authored
Merge branch 'main' into owl-bot-update-lock-a52bd494fc1fe28479d7982db3d0f8bd49d862b4184c4574ca0931e99ac1ffee
2 parents 1c58161 + 47517b2 commit 1f30018

33 files changed

+1751
-190
lines changed

.github/.OwlBot.lock.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest
16-
digest: sha256:a52bd494fc1fe28479d7982db3d0f8bd49d862b4184c4574ca0931e99ac1ffee
17-
# created: 2025-07-15T17:18:59.198670588Z
16+
digest: sha256:84adf917cad8f48c61227febebae7af619882d7c8863d6ab6290a77d45a372cf
17+
# created: 2025-09-10T20:42:34.536728816Z

.github/workflows/ci.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
matrix:
1212
node: [18, 20, 22, 24]
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v5
1515
- uses: actions/setup-node@v4
1616
with:
1717
node-version: ${{ matrix.node }}
@@ -29,7 +29,7 @@ jobs:
2929
test-script:
3030
runs-on: ubuntu-latest
3131
steps:
32-
- uses: actions/checkout@v4
32+
- uses: actions/checkout@v5
3333
- uses: actions/setup-node@v4
3434
with:
3535
node-version: 18
@@ -43,7 +43,7 @@ jobs:
4343
windows:
4444
runs-on: windows-latest
4545
steps:
46-
- uses: actions/checkout@v4
46+
- uses: actions/checkout@v5
4747
- uses: actions/setup-node@v4
4848
with:
4949
node-version: 18
@@ -54,7 +54,7 @@ jobs:
5454
lint:
5555
runs-on: ubuntu-latest
5656
steps:
57-
- uses: actions/checkout@v4
57+
- uses: actions/checkout@v5
5858
- uses: actions/setup-node@v4
5959
with:
6060
node-version: 18
@@ -63,7 +63,7 @@ jobs:
6363
docs:
6464
runs-on: ubuntu-latest
6565
steps:
66-
- uses: actions/checkout@v4
66+
- uses: actions/checkout@v5
6767
- uses: actions/setup-node@v4
6868
with:
6969
node-version: 18

.github/workflows/issues-no-repro.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
issues: write
1111
pull-requests: write
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v5
1414
- uses: actions/setup-node@v4
1515
with:
1616
node-version: 18

.github/workflows/response.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
issues: write
1414
pull-requests: write
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717
- uses: actions/github-script@v7
1818
with:
1919
script: |
@@ -27,7 +27,7 @@ jobs:
2727
issues: write
2828
pull-requests: write
2929
steps:
30-
- uses: actions/checkout@v4
30+
- uses: actions/checkout@v5
3131
- uses: actions/github-script@v7
3232
with:
3333
script: |

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
[1]: https://www.npmjs.com/package/@google-cloud/pubsub?activeTab=versions
66

7+
## [5.2.0](https://github.com/googleapis/nodejs-pubsub/compare/v5.1.0...v5.2.0) (2025-08-07)
8+
9+
10+
### Features
11+
12+
* Ad-hoc, targeted debug logging ([#2062](https://github.com/googleapis/nodejs-pubsub/issues/2062)) ([dce83c7](https://github.com/googleapis/nodejs-pubsub/commit/dce83c71bba54388334f4f73115e7b8da6fbdb67))
13+
* Add timeout option and graceful shutdown to Subscription.close() ([#2068](https://github.com/googleapis/nodejs-pubsub/issues/2068)) ([8dee024](https://github.com/googleapis/nodejs-pubsub/commit/8dee0248081f7156e42d79c6067902583586faf2))
14+
715
## [5.1.0](https://github.com/googleapis/nodejs-pubsub/compare/v5.0.0...v5.1.0) (2025-06-04)
816

917

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-pubsub/tree
123123

124124
| Sample | Source Code | Try it |
125125
| --------------------------- | --------------------------------- | ------ |
126+
| Close Subscription with Timeout | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/closeSubscriptionWithTimeout.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/closeSubscriptionWithTimeout.js,samples/README.md) |
126127
| Commit an Avro-Based Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/commitAvroSchema.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/commitAvroSchema.js,samples/README.md) |
127128
| Commit an Proto-Based Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/commitProtoSchema.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/commitProtoSchema.js,samples/README.md) |
128129
| Create an Avro based Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createAvroSchema.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createAvroSchema.js,samples/README.md) |

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@google-cloud/pubsub",
33
"description": "Cloud Pub/Sub Client Library for Node.js",
4-
"version": "5.1.0",
4+
"version": "5.2.0",
55
"license": "Apache-2.0",
66
"author": "Google Inc.",
77
"engines": {
@@ -65,7 +65,7 @@
6565
"p-defer": "^3.0.0"
6666
},
6767
"devDependencies": {
68-
"@grpc/proto-loader": "^0.7.13",
68+
"@grpc/proto-loader": "^0.8.0",
6969
"@opentelemetry/sdk-trace-base": "^1.17.0",
7070
"@types/duplexify": "^3.6.4",
7171
"@types/extend": "^3.0.4",

samples/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ guides.
2020

2121
* [Before you begin](#before-you-begin)
2222
* [Samples](#samples)
23+
* [Close Subscription with Timeout](#close-subscription-with-timeout)
2324
* [Commit an Avro-Based Schema](#commit-an-avro-based-schema)
2425
* [Commit an Proto-Based Schema](#commit-an-proto-based-schema)
2526
* [Create an Avro based Schema](#create-an-avro-based-schema)
@@ -108,6 +109,25 @@ Before running the samples, make sure you've followed the steps outlined in
108109

109110

110111

112+
### Close Subscription with Timeout
113+
114+
Demonstrates closing a subscription with a specified timeout for graceful shutdown.
115+
116+
View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/closeSubscriptionWithTimeout.js).
117+
118+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/closeSubscriptionWithTimeout.js,samples/README.md)
119+
120+
__Usage:__
121+
122+
123+
`node closeSubscriptionWithTimeout.js <topic-name> <subscription-name>`
124+
125+
126+
-----
127+
128+
129+
130+
111131
### Commit an Avro-Based Schema
112132

113133
Commits a new schema definition revision on a project, using Avro
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// This is a generated sample, using the typeless sample bot. Please
16+
// look for the source TypeScript sample (.ts) for modifications.
17+
'use strict';
18+
19+
/**
20+
* This sample demonstrates how to use the `timeout` option when closing a Pub/Sub
21+
* subscription using the Node.js client library. The timeout allows for graceful
22+
* shutdown, attempting to nack any buffered messages before closing.
23+
*
24+
* For more information, see the README.md under /pubsub and the documentation
25+
* at https://cloud.google.com/pubsub/docs.
26+
*/
27+
28+
// sample-metadata:
29+
// title: Close Subscription with Timeout
30+
// description: Demonstrates closing a subscription with a specified timeout for graceful shutdown.
31+
// usage: node closeSubscriptionWithTimeout.js <topic-name> <subscription-name>
32+
33+
// This sample is currently speculative.
34+
// -START pubsub_close_subscription_with_timeout]
35+
36+
// Imports the Google Cloud client library
37+
const {
38+
PubSub,
39+
Duration,
40+
SubscriptionCloseBehaviors,
41+
} = require('@google-cloud/pubsub');
42+
43+
// Creates a client; cache this for further use
44+
const pubsub = new PubSub();
45+
46+
async function closeSubscriptionWithTimeout(
47+
topicNameOrId,
48+
subscriptionNameOrId,
49+
) {
50+
const topic = pubsub.topic(topicNameOrId);
51+
52+
// Closes the subscription immediately, not waiting for anything.
53+
let subscription = topic.subscription(subscriptionNameOrId, {
54+
closeOptions: {
55+
timeout: Duration.from({seconds: 0}),
56+
},
57+
});
58+
await subscription.close();
59+
60+
// Shuts down the gRPC connection, and waits for just before the timeout
61+
// to send nacks for buffered messages. If `timeout` were missing, this
62+
// would wait for the maximum leasing timeout.
63+
subscription = topic.subscription(subscriptionNameOrId, {
64+
closeOptions: {
65+
behavior: SubscriptionCloseBehaviors.WaitForProcessing,
66+
timeout: Duration.from({seconds: 10}),
67+
},
68+
});
69+
await subscription.close();
70+
71+
// Shuts down the gRPC connection, sends nacks for buffered messages, and waits
72+
// through the timeout for nacks to send.
73+
subscription = topic.subscription(subscriptionNameOrId, {
74+
closeOptions: {
75+
behavior: SubscriptionCloseBehaviors.NackImmediately,
76+
timeout: Duration.from({seconds: 10}),
77+
},
78+
});
79+
await subscription.close();
80+
}
81+
// -END pubsub_close_subscription_with_timeout]
82+
83+
// Presumes topic and subscription have been created prior to running the sample.
84+
// If you uncomment the cleanup code above, the sample will delete them afterwards.
85+
function main(
86+
topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID',
87+
subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID',
88+
) {
89+
closeSubscriptionWithTimeout(topicNameOrId, subscriptionNameOrId).catch(
90+
err => {
91+
console.error(err.message);
92+
process.exitCode = 1;
93+
},
94+
);
95+
}
96+
97+
main(...process.argv.slice(2));

samples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"dependencies": {
2727
"@google-cloud/opentelemetry-cloud-trace-exporter": "^2.0.0",
28-
"@google-cloud/pubsub": "^5.1.0",
28+
"@google-cloud/pubsub": "^5.2.0",
2929
"@google-cloud/storage": "^7.11.1",
3030
"@opentelemetry/api": "^1.6.0",
3131
"@opentelemetry/resources": "^1.17.0",

0 commit comments

Comments
 (0)