Repository navigation
Conversation
There was a problem hiding this comment.
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.
| // eslint-disable-next-line promise/catch-or-return | ||
| this._subscriber.close().then(() => callback!(), callback); |
There was a problem hiding this comment.
There is a bug in the close method when it is called without a callback (i.e., as a Promise-returning function):
- If
callbackis undefined,callback!()will be executed when the promise resolves, throwing aTypeError: callback is not a functionerror. - The method does not return the promise when
callbackis omitted, meaning callers awaitingsubscription.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();
}|
This is just preliminary test-run work on this one. |
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
handwritten/pubsub/test/gapic_publisher_v1.ts,test/gapic_schema_service_v1.ts, andtest/gapic_subscriber_v1.ts(289 tests duplicatingpackages/google-cloud-pubsub-api/test/gapic_*_v1.ts).handwritten/pubsub/src/v1-old/config files and updatesrc/message-stream.ts(andtest/message-stream.ts) to loadsubscriber_client_config.jsonfrom@google-cloud/pubsub-api.handwritten/pubsub/protos/protos.jsonandprotos/google/pubsub/v1/*.proto, migrate all 17 internalsrc/,test/, andsystem-test/imports from../protos/protosto@google-cloud/pubsub-api, and remove"protos/protos.json"fromtsconfig.jsonand the deadcompile-protosscript frompackage.json.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
pnpm --dir handwritten/pubsub run compile: passed with 0 errors.pnpm --dir handwritten/pubsub test: 697 passing, 0 failing, 0 skipped.GIT_DIFF_ARG=HEAD node ./bin/linter.mjs --strict: passed with 0 errors and 0 warnings across all touched files.pnpm --dir handwritten/pubsub run docs: passed.BREAKING_CHANGE_BASE_REF=HEAD pnpm --dir core/test-utils run check: passed (No breaking public TypeScript interface changes detected.).Alternatives
protos/protos.{js,d.ts}in the same PR causesbreaking-change-checkfalse positives becauseprotos/is ignored when constructing the base overlay; if desired, those two shims can be removed in a follow-up PR after this merges.