Repository navigation
Conversation
There was a problem hiding this comment.
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.
| // eslint-disable-next-line promise/catch-or-return | ||
| this._subscriber.close().then(() => callback!(), callback); |
There was a problem hiding this comment.
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();
}| require('@google-cloud/pubsub-api/build/src/v1/subscriber_client_config.json') | ||
| .interfaces['google.pubsub.v1.Subscriber'].methods.StreamingPull | ||
| .timeout_millis; |
There was a problem hiding this comment.
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
- Avoid hardcoding relative paths to dependencies in node_modules. Instead, resolve the path dynamically using require.resolve and path.join.
|
This is just preliminary test-run work on this one. |
|
Closing fork PR to move into a GitHub Stack directly on googleapis/google-cloud-node. |
|
Moved to stacked draft PR #9903. |
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.