Skip to content

chore(pubsub): [C09] remove duplicate GAPIC tests, v1-old, and protos - #9903

Draft
feywind wants to merge 1 commit into
c09/bigquery-storage-large-request-testfrom
c09/pubsub-delete-redundant-gapic
Draft

feywind wants to merge 1 commit into
c09/bigquery-storage-large-request-testfrom
c09/pubsub-delete-redundant-gapic

Conversation

@feywind

@feywind feywind commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Removes duplicate GAPIC tests, orphaned v1-old configs, and unused proto files.

Impact

Eliminates 289 redundant unit tests and 17,000+ lines of duplicated files.

Changes

  • Delete handwritten/pubsub/test/gapic_publisher_v1.ts, test/gapic_schema_service_v1.ts, and test/gapic_subscriber_v1.ts (289 tests duplicating packages/google-cloud-pubsub-api/test/gapic_*_v1.ts).
  • Delete orphaned handwritten/pubsub/src/v1-old/ config files and update src/message-stream.ts (and test/message-stream.ts) to load subscriber_client_config.json from @google-cloud/pubsub-api.
  • Delete handwritten/pubsub/protos/protos.json and protos/google/pubsub/v1/*.proto, migrate all 17 internal src/, test/, and system-test/ imports from ../protos/protos to @google-cloud/pubsub-api, and remove "protos/protos.json" from tsconfig.json and the dead compile-protos script from package.json.
  • Retain only the two 15-line protos/protos.{js,d.ts} re-export shims for subpath compatibility (@google-cloud/pubsub/build/protos/protos) and to keep the public TypeScript breaking-change check passing in a single PR.

Testing

  • Ran pnpm --dir handwritten/pubsub run compile: passed with 0 errors.
  • Ran pnpm --dir handwritten/pubsub test: 697 passing, 0 failing, 0 skipped.
  • Ran GIT_DIFF_ARG=HEAD node ./bin/linter.mjs --strict: passed with 0 errors and 0 warnings across all touched files.
  • Ran pnpm --dir handwritten/pubsub run docs: passed.
  • Ran BREAKING_CHANGE_BASE_REF=HEAD pnpm --dir core/test-utils run check: passed (No breaking public TypeScript interface changes detected.).

Alternatives

  • Keeping the three duplicate GAPIC unit test files runs 289 identical mock tests on every pull request across all 7 GitHub Actions runtime jobs (2,023 redundant executions per PR).
  • Deleting protos/protos.{js,d.ts} in the same PR causes breaking-change-check false positives because protos/ is ignored when constructing the base overlay; if desired, those two shims can be removed in a follow-up PR after this merges.

@product-auto-label product-auto-label Bot added the api: pubsub Issues related to the Pub/Sub API. label Nov 18, 2026
@feywind
feywind added this pull request to stack #9907 November 18, 2026 22:47

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the Pub/Sub handwritten library to use the external '@google-cloud/pubsub-api' package for proto definitions and client configurations, allowing the removal of local proto files, generated client configurations, and generated tests. A review comment identified a critical bug in the 'Subscription.close' method where calling it without a callback throws a 'TypeError' and fails to return the promise.

Comment on lines +385 to 386
// eslint-disable-next-line promise/catch-or-return
this._subscriber.close().then(() => callback!(), callback);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

There is a bug in the close method when it is called without a callback (i.e., as a Promise-returning function):

  1. If callback is undefined, callback!() will be executed when the promise resolves, throwing a TypeError: callback is not a function error.
  2. The method does not return the promise when callback is omitted, meaning callers awaiting subscription.close() will not actually wait for the subscriber to close.

We should conditionally handle the presence of the callback and return the promise when it is not provided.

    if (callback) {
      // eslint-disable-next-line promise/catch-or-return
      this._subscriber.close().then(() => callback(), callback);
    } else {
      return this._subscriber.close();
    }

@feywind

feywind commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

This is just preliminary test-run work on this one.

This branch has not been deployed

No deployments
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 Pub/Sub API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant