Skip to content

chore(pubsub): remove duplicate GAPIC tests, v1-old configs, and protos - #9888

Closed
feywind wants to merge 1 commit into
googleapis:mainfrom
feywind:c09/pubsub-delete-redundant-gapic
Closed

feywind wants to merge 1 commit into
googleapis:mainfrom
feywind:c09/pubsub-delete-redundant-gapic

Conversation

@feywind

@feywind feywind commented Nov 17, 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 17, 2026

@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 removes local proto files and generated client tests, transitioning the codebase to import protobuf definitions directly from the external @google-cloud/pubsub-api package. It also updates the build and configuration files accordingly. Feedback on these changes suggests safely handling the optional callback in Subscription.close() to avoid disabling ESLint rules and using non-null assertions, as well as dynamically resolving the path to subscriber_client_config.json using require.resolve instead of hardcoding a deep path into node_modules.

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.

medium

Instead of disabling the ESLint rule and using the non-null assertion operator (!), we can handle the optional callback safely. If callback is not provided, we can directly return the promise returned by this._subscriber.close(). This satisfies the ESLint rule naturally, avoids the ! operator, and prevents a potential runtime TypeError if the method is ever called without a callback (e.g., if promisification is bypassed or not applied).

    if (callback) {
      this._subscriber.close().then(() => callback(), callback);
    } else {
      return this._subscriber.close();
    }

Comment on lines +53 to +55
require('@google-cloud/pubsub-api/build/src/v1/subscriber_client_config.json')
.interfaces['google.pubsub.v1.Subscriber'].methods.StreamingPull
.timeout_millis;

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.

medium

Deeply requiring files from the build/src/ directory of an external package like @google-cloud/pubsub-api is risky. The build/src/ structure is an implementation detail of the build process and can change. Instead of hardcoding relative paths, resolve the path dynamically using require.resolve and path.join to ensure robustness across different environments and directory structures.

References
  1. Avoid hardcoding relative paths to dependencies in node_modules. Instead, resolve the path dynamically using require.resolve and path.join.

@feywind

feywind commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

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

@feywind

feywind commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Closing fork PR to move into a GitHub Stack directly on googleapis/google-cloud-node.

@feywind feywind closed this Nov 18, 2026
@feywind
feywind deleted the c09/pubsub-delete-redundant-gapic branch November 18, 2026 22:37
@feywind

feywind commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Moved to stacked draft PR #9903.

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