Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when deleting subscription just before closing the client #1323

Closed
noe-charmet opened this issue Jun 18, 2021 · 2 comments
Closed

Error when deleting subscription just before closing the client #1323

noe-charmet opened this issue Jun 18, 2021 · 2 comments
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@noe-charmet
Copy link

After a recent update (can't same from which version it was unfortunately). We have started seeing errors in our logs coming from this client, when deleting a subscription just before closing the client.

Environment details

  • OS: Linux (Alpine)
  • Node.js version: 16
  • npm version: 7.11.2
  • @google-cloud/pubsub version: 2.13.0

Steps to reproduce

const client = new PubSub({
  projectId: // Project ID,
  autoRetry: true,
});
const topic = 'MyTopic';
const subscriptionName = 'MySubscription'
const subscription = client.topic(topic).subscription(subscriptionName);
const [subscriptionInstance] = await subscription.get({autoCreate: true});
await this.subscriptionInstance.delete();
await client.close();

Error

Cannot use a closed PubSub object.
    at PubSub.request (/rolo/node_modules/@google-cloud/pubsub/src/pubsub.ts:1267:19)
    at Subscription.delete (/rolo/node_modules/@google-cloud/pubsub/src/subscription.ts:560:10)
    at /rolo/node_modules/@google-cloud/promisify/build/src/index.js:57:28
    at new Promise (<anonymous>)
    at Subscription.wrapper (/rolo/node_modules/@google-cloud/promisify/build/src/index.js:42:16)
    at Subscriber.shutdown (/rolo/node_modules/@rolo-chat/server-engine/src/entities/Subscriber/Subscriber.js:106:15)
    at callback (/rolo/node_modules/@rolo-chat/server-engine/src/entities/Server/Server.js:194:46)
    at Array.map (<anonymous>)
    at Server.<anonymous> (/rolo/node_modules/@rolo-chat/server-engine/src/entities/Server/Server.js:193:34)
    at Server.emit (node:events:406:35)
    at Server.incomingRequest (/rolo/node_modules/@opentelemetry/plugin-http/src/http.ts:279:25)
    at emitCloseNT (node:net:1648:8)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

Could it be linked to the fact that we are also using open telemetry in our stack. Could this cause some kind of conflict?

@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/nodejs-pubsub API. label Jun 18, 2021
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jun 19, 2021
@feywind
Copy link
Collaborator

feywind commented Jun 22, 2021

@noe-charmet I don't think it would be the OpenTelemetry, unless that just happens to delay the processing of outstanding promises, and triggers a race condition, or something like that. There's this comment on client.close():

   * Closes out this object, releasing any server connections. Note that once
   * you close a PubSub object, it may not be used again. Any pending operations
   * (e.g. queued publish messages) will fail. If you have topic or subscription
   * objects that may have pending operations, you should call close() on those
   * first if you want any pending messages to be delivered correctly. The
   * PubSub class doesn't track those.

Sadly there isn't a thing to track when you're doing a delete operation on the client itself, which seems like a bit of an oversight.

Vaguely related request: #725 (more deterministic shutdown)

@feywind feywind added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed triage me I really want to be triaged. labels Jun 22, 2021
@feywind
Copy link
Collaborator

feywind commented Mar 24, 2022

Moving this to the internal backlog alongside 725.

@feywind feywind closed this as completed Mar 24, 2022
feywind pushed a commit to feywind/nodejs-pubsub that referenced this issue Nov 12, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/checkout](https://togithub.com/actions/checkout) | action | major | `v3` -> `v4` |

---

### Release Notes

<details>
<summary>actions/checkout (actions/checkout)</summary>

### [`v4`](https://togithub.com/actions/checkout/blob/HEAD/CHANGELOG.md#v400)

[Compare Source](https://togithub.com/actions/checkout/compare/v3...v4)

-   [Support fetching without the --progress option](https://togithub.com/actions/checkout/pull/1067)
-   [Update to node20](https://togithub.com/actions/checkout/pull/1436)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 9am and before 3pm" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/googleapis/nodejs-bigtable).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi43OS4xIiwidXBkYXRlZEluVmVyIjoiMzYuNzkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants