feat: support restify v9-v11 by 6utt3rfly · Pull Request #1489 · googleapis/cloud-trace-nodejs · GitHub
Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

feat: support restify v9-v11#1489

Merged
gcf-merge-on-green[bot] merged 6 commits into
googleapis:mainfrom
betastreet:feat/restify11
Apr 25, 2023
Merged

feat: support restify v9-v11#1489
gcf-merge-on-green[bot] merged 6 commits into
googleapis:mainfrom
betastreet:feat/restify11

Conversation

@6utt3rfly

@6utt3rfly 6utt3rfly commented Mar 7, 2023

Copy link
Copy Markdown
Contributor

Fixes #1488

(see also #1250 for reference)

@6utt3rfly 6utt3rfly requested review from a team March 7, 2023 21:28
@google-cla

google-cla Bot commented Mar 7, 2023

Copy link
Copy Markdown

@product-auto-label product-auto-label Bot added the size: s Pull request size is small. label Mar 7, 2023
@generated-files-bot

Copy link
Copy Markdown

Warning: This pull request is touching the following templated files:

@product-auto-label product-auto-label Bot added the api: cloudtrace Issues related to the googleapis/cloud-trace-nodejs API. label Mar 7, 2023
@punya punya added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 28, 2023
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 28, 2023
@punya

punya commented Mar 29, 2023

Copy link
Copy Markdown
Contributor

@6utt3rfly, thanks for the contribution. Please take a look at the test failures. For example,

  1) Web framework tracing
       Tracing restify@9
         "before all" hook for "accurately measures get time (1 handler)":

      AssertionError [ERR_ASSERTION]: Handler [handler-0 on GET /one-handler] accepts a third argument (the 'next" callback) but is also an async function. Middleware handlers can be either async/await or callback-based. Async handler functions should accept maximum of 2 arguments: (req, res). Non-async handlers should accept three arguments: (req, res, next).
      + expected - actual


      at Chain.add (test/plugins/fixtures/restify9/node_modules/restify/lib/chain.js:91:16)
      at forEach (test/plugins/fixtures/restify9/node_modules/restify/lib/router.js:211:15)
      at Array.forEach (<anonymous>)
      at Router.mount (test/plugins/fixtures/restify9/node_modules/restify/lib/router.js:203:14)
      at Server.serverMethod [as get] (test/plugins/fixtures/restify9/node_modules/restify/lib/server.js:1750:33)
      at _a.addHandler (/home/runner/work/cloud-trace-nodejs/cloud-trace-nodejs/test/web-frameworks/restify.ts:38:19)
      at Context.<anonymous> (/home/runner/work/cloud-trace-nodejs/cloud-trace-nodejs/test/test-trace-web-frameworks.ts:113:22)
      at processImmediate (node:internal/timers:466:21)
      at process.topLevelDomainCallback (node:domain:161:15)
      at process.callbackTrampoline (node:internal/async_hooks:128:24)

Could you confirm whether you've tested this change locally, and with what versions?

Restify 9 added async/await support, but it requires that middleware either be `async (req, res)` or `(req, res, next)`, but not both: `async (req, res, next)`. The restify test now avoids async/await and directly uses Promises to maintain backward compatibility with earlier versions of restify
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Apr 13, 2023
@6utt3rfly 6utt3rfly changed the title Support Restify v9-v11 feat: support restify v9-v11 Apr 13, 2023
@6utt3rfly

Copy link
Copy Markdown
Contributor Author

@punya - I had trouble running local unit tests until I saw this PR's build log and realized I needed docker images running (or TRACE_TEST_EXCLUDE_INTEGRATION set). It might be worth adding something to the CONTRIBUTING.md file?

The existing restify plugin works if I manually patch the SUPPORTED_VERSIONS. I've pushed a commit to fix the failing unit test by avoiding async (req, res, next), which breaks in restify 9+

@punya punya 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.

Thanks for looking into it @6utt3rfly! I have a couple of small suggestions, but otherwise this looks good to me.

Comment thread test/web-frameworks/restify.ts Outdated
Comment thread test/web-frameworks/restify.ts Outdated
6utt3rfly and others added 2 commits April 13, 2023 15:04
Co-authored-by: Punya Biswal <punya@google.com>
Co-authored-by: Punya Biswal <punya@google.com>
@6utt3rfly

Copy link
Copy Markdown
Contributor Author

Thanks for looking into it @6utt3rfly! I have a couple of small suggestions, but otherwise this looks good to me.

I actually hadn't noticed .then accepts both resolve and reject, and thought it was only in new Promise(resolve, reject), so I like your suggestion!

@punya

punya commented Apr 13, 2023

Copy link
Copy Markdown
Contributor

I see some lint failures that should be easy to fix:

/home/runner/work/cloud-trace-nodejs/cloud-trace-nodejs/test/web-frameworks/restify.ts
Warning:   20:3   warning  'WebFrameworkResponse' is defined but never used  @typescript-eslint/no-unused-vars
Error:   41:17  error    Replace `(response)` with `response`              prettier/prettier

But there are also several failing tests (starting at https://github.com/googleapis/cloud-trace-nodejs/actions/runs/4694210640/jobs/8322181339?pr=1489#step:7:2986) that I don't understand.

Reading the Restify docs in some more detail, I'm not sure that we're supposed to use 3-argument handlers with Promises (regardless of whether we use async/await syntax to generate the Promise).

I wonder if it might be necessary to have totally different code paths for Restify <= v8 and Restify >= v9.

Unit tests with restify 9-11 on node 12 reports, "Cannot find node module 'node:process'", which indicates a node compatibility issue
@6utt3rfly

Copy link
Copy Markdown
Contributor Author

@punya - Cannot find node module 'node:process' seems to indicate a node compatibility issue with restify (even though their release notes indicate node 10 and 12 support). Are you okay with restricting the unit tests to node 14+ (see commit)?

@6utt3rfly 6utt3rfly requested a review from punya April 24, 2023 16:14
@punya punya added kokoro:run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Apr 25, 2023
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 25, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 25, 2023
@punya punya added the automerge Merge the pull request once unit tests and other checks pass. label Apr 25, 2023
@gcf-merge-on-green gcf-merge-on-green Bot merged commit 746f30c into googleapis:main Apr 25, 2023
@gcf-merge-on-green gcf-merge-on-green Bot removed the automerge Merge the pull request once unit tests and other checks pass. label Apr 25, 2023
@6utt3rfly 6utt3rfly deleted the feat/restify11 branch April 25, 2023 15:12
@6utt3rfly

Copy link
Copy Markdown
Contributor Author

gcf-merge-on-green Bot pushed a commit that referenced this pull request Feb 7, 2024
🤖 I have created a release *beep* *boop*
---


## [8.0.0](https://togithub.com/googleapis/cloud-trace-nodejs/compare/v7.1.2...v8.0.0) (2024-02-07)


### ⚠ BREAKING CHANGES

* upgrade to Node 14 ([#1517](https://togithub.com/googleapis/cloud-trace-nodejs/issues/1517))

### Features

* Support restify v9-v11 ([#1489](https://togithub.com/googleapis/cloud-trace-nodejs/issues/1489)) ([746f30c](https://togithub.com/googleapis/cloud-trace-nodejs/commit/746f30c084f8e2c9eb9dbaebb017ed3cc30304ca))


### Bug Fixes

* Assert oldMethod existence, and pin typescript version ([#1549](https://togithub.com/googleapis/cloud-trace-nodejs/issues/1549)) ([66a39fa](https://togithub.com/googleapis/cloud-trace-nodejs/commit/66a39fac603dbd0ab40afa5266236850124cd21b))
* **deps:** Update dependency require-in-the-middle to v6 ([#1483](https://togithub.com/googleapis/cloud-trace-nodejs/issues/1483)) ([ddd4bbb](https://togithub.com/googleapis/cloud-trace-nodejs/commit/ddd4bbb765aaa698ace8ec35ae79331f930a6709))
* **deps:** Update dependency require-in-the-middle to v7 ([#1494](https://togithub.com/googleapis/cloud-trace-nodejs/issues/1494)) ([58e7821](https://togithub.com/googleapis/cloud-trace-nodejs/commit/58e7821ce4abcba934431b9623bfef28c17da959))
* Skip flaky test ([#1495](https://togithub.com/googleapis/cloud-trace-nodejs/issues/1495)) ([bb03060](https://togithub.com/googleapis/cloud-trace-nodejs/commit/bb03060c6cf6e9d80982dda9dbb62aa3704daedf)), closes [#1334](https://togithub.com/googleapis/cloud-trace-nodejs/issues/1334)


### Miscellaneous Chores

* Upgrade to Node 14 ([#1517](https://togithub.com/googleapis/cloud-trace-nodejs/issues/1517)) ([8b6c967](https://togithub.com/googleapis/cloud-trace-nodejs/commit/8b6c967a73eb3ce16b1a4471249f4266db32e478))

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: cloudtrace Issues related to the googleapis/cloud-trace-nodejs API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Restify Plugin to support Restify versions 9-11

3 participants