Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support restify v9-v11 #1489

Merged
merged 6 commits into from Apr 25, 2023
Merged

feat: support restify v9-v11 #1489

merged 6 commits into from Apr 25, 2023

Conversation

6utt3rfly
Copy link
Contributor

@6utt3rfly 6utt3rfly commented Mar 7, 2023

Fixes #1488

(see also #1250 for reference)

@6utt3rfly 6utt3rfly requested review from a team as code owners March 7, 2023 21:28
@google-cla
Copy link

google-cla bot commented Mar 7, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@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

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
Copy link
Contributor

punya commented Mar 29, 2023

@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
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+

Copy link
Contributor

@punya punya left a comment

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.

test/web-frameworks/restify.ts Outdated Show resolved Hide resolved
test/web-frameworks/restify.ts Outdated Show resolved Hide resolved
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
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
Copy link
Contributor

punya commented Apr 13, 2023

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
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
15 checks passed
@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
Contributor Author

@punya - I'm not sure why the release action hanged (5h 58m!), because it looks like everything passed, but then it didn't get the coverage
image

vs the PR test:
image

... maybe worth just retrying that job?

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 join this conversation on GitHub. Already have an account? Sign in to comment
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