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: Attempt to warm http2 connection upon SDK startup #1201

Merged
merged 2 commits into from
Jul 31, 2024

Conversation

blaine-arcjet
Copy link
Contributor

@blaine-arcjet blaine-arcjet commented Jul 26, 2024

This updates our HTTP2 transport to attempt the connect() of the HTTP2 connection upon initialization. It also sets a 600 second timeout on the connection.

This most benefits long-running servers, but improvements can also be seen in warm serverless functions.

Copy link

trunk-io bot commented Jul 26, 2024

😎 Merged successfully - details.

@blaine-arcjet
Copy link
Contributor Author

I tested Bun and it doesn't emit any events on the HTTP/2 stream. I spent the afternoon trying to dig into their source code and compare the @grpc/grpc-js implementation (which they claim works) with connectrpc and can't figure it out. So I just reverted the bun adapter back to HTTP/1.1 until they make it work correctly.

@blaine-arcjet blaine-arcjet marked this pull request as ready for review July 29, 2024 21:41
@blaine-arcjet blaine-arcjet requested a review from a team as a code owner July 29, 2024 21:41
@davidmytton
Copy link
Contributor

Are we not supporting Next.js with this as well?

@blaine-arcjet
Copy link
Contributor Author

Are we not supporting Next.js with this as well?

Looking at our Next adapter, it uses @connectrpc/connect-web dependency. The comment states:

// Transport is the HTTP client that the client uses to make requests.
// The Connect Node client doesn't work on edge runtimes: https://github.com/bufbuild/connect-es/pull/589
// so set the transport using connect-web. The interceptor is required for it work in the edge runtime.

Node imports are forbidden in the edge runtime, so we'd need to implement near-duplicate files like we do for @arcjet/analyze to support different transports inside one package.

@davidmytton
Copy link
Contributor

Ah yes, I remember. We definitely want to do this for Next.js as well - do you want to do that as a separate PR?

trunk-io bot pushed a commit that referenced this pull request Jul 30, 2024
#1221)

This moves our transport logic into its own package. This allows us to leverage [conditional exports](https://nodejs.org/docs/latest-v18.x/api/packages.html#conditional-exports) to support `bun` and `edge-light` which need additional considerations for their transports.

Right now, this package is very thin, as it just calls out to the correct Connect-RPC functions for the correct runtime, but we'll also be able to consolidate our HTTP/2 Session logic from #1201 and build our custom transport in a single place (in the future).

During development, I added console.log statements to verify the correct `createTransport` was being called based on the runtime, but I don't want to thread the logger into here so I just removed them before submitting the PR.
@blaine-arcjet blaine-arcjet force-pushed the phated/connect-http2-startup branch from faf4b2e to 3faaa4d Compare July 30, 2024 18:54
@blaine-arcjet blaine-arcjet changed the title chore: Attempt to warm http2 connection upon SDK startup feat: Attempt to warm http2 connection upon SDK startup Jul 30, 2024
@blaine-arcjet
Copy link
Contributor Author

@davidmytton this should be ready to review

Copy link
Contributor

@davidmytton davidmytton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I've tested Next.js on Vercel with edge middleware and serverless functions. Serverless functions show the expected behavior of the initial connection latency being the highest and then subsequent requests being much faster. There wasn't any improvement in the latency on the edge middleware - latency is the same for every request.

transport/index.ts Outdated Show resolved Hide resolved
@trunk-io trunk-io bot merged commit a5c2571 into main Jul 31, 2024
21 checks passed
@trunk-io trunk-io bot deleted the phated/connect-http2-startup branch July 31, 2024 13:18
trunk-io bot pushed a commit that referenced this pull request Aug 5, 2024
Automatically generated with [Release Please](https://github.com/googleapis/release-please).
---


<details><summary>@arcjet/analyze: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/analyze-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/analyze:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @arcjet/protocol bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/bun: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/bun-v1.0.0-alpha.21) (2024-08-05)


### 🚀 New Features

* Abstract transports into package to leverage conditional exports ([#1221](#1221)) ([27776f7](27776f7))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @arcjet/env bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/headers bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/ip bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/logger bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/protocol bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/transport bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * arcjet bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/decorate: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/decorate-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/decorate:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @arcjet/protocol bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/sprintf bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/duration: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/duration-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/duration:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/env: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/env-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/env:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/eslint-config: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/eslint-config-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/eslint-config:** Synchronize arcjet-js versions
</details>

<details><summary>@arcjet/headers: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/headers-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/headers:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/ip: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/ip-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/ip:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/logger: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/logger-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/logger:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @arcjet/sprintf bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/next: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/next-v1.0.0-alpha.21) (2024-08-05)


### 🚀 New Features

* Abstract transports into package to leverage conditional exports ([#1221](#1221)) ([27776f7](27776f7))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @arcjet/env bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/headers bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/ip bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/logger bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/protocol bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/transport bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * arcjet bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/node: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/node-v1.0.0-alpha.21) (2024-08-05)


### 🚀 New Features

* Abstract transports into package to leverage conditional exports ([#1221](#1221)) ([27776f7](27776f7))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @arcjet/env bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/headers bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/ip bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/logger bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/protocol bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/transport bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * arcjet bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/protocol: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/protocol-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/protocol:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/rollup-config: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/rollup-config-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/rollup-config:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/runtime: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/runtime-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/runtime:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/sprintf: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/sprintf-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/sprintf:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/sveltekit: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/sveltekit-v1.0.0-alpha.21) (2024-08-05)


### 🚀 New Features

* Abstract transports into package to leverage conditional exports ([#1221](#1221)) ([27776f7](27776f7))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @arcjet/env bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/headers bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/ip bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/logger bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/protocol bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/transport bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * arcjet bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/transport: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/transport-v1.0.0-alpha.21) (2024-08-05)


### 🚀 New Features

* Abstract transports into package to leverage conditional exports ([#1221](#1221)) ([27776f7](27776f7))
* Attempt to warm http2 connection upon SDK startup ([#1201](#1201)) ([a5c2571](a5c2571))


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>@arcjet/tsconfig: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.20...@arcjet/tsconfig-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **@arcjet/tsconfig:** Synchronize arcjet-js versions
</details>

<details><summary>arcjet: 1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](v1.0.0-alpha.20...arcjet-v1.0.0-alpha.21) (2024-08-05)


### 🧹 Miscellaneous Chores

* **arcjet:** Synchronize arcjet-js versions


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @arcjet/analyze bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/duration bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/headers bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/protocol bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/runtime bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
  * devDependencies
    * @arcjet/eslint-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/rollup-config bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
    * @arcjet/tsconfig bumped from 1.0.0-alpha.20 to 1.0.0-alpha.21
</details>

<details><summary>1.0.0-alpha.21</summary>

## [1.0.0-alpha.21](v1.0.0-alpha.20...v1.0.0-alpha.21) (2024-08-05)


### 🚀 New Features

* Abstract transports into package to leverage conditional exports ([#1221](#1221)) ([27776f7](27776f7))
* Attempt to warm http2 connection upon SDK startup ([#1201](#1201)) ([a5c2571](a5c2571))


### 🧹 Miscellaneous Chores

* **ci:** Change the dependabot commit prefix for Actions PRs ([#1231](#1231)) ([4dac6d5](4dac6d5))
* **ci:** Ignore typescript-eslint 8 until we upgrade to eslint 9 ([#1263](#1263)) ([b089de2](b089de2)), closes [#539](#539)
* **ci:** Leverage Dependabot to update our GitHub Actions ([#1222](#1222)) ([ffde70a](ffde70a))
* **ci:** Switch release-please-action location & update to latest version ([#1229](#1229)) ([e44d81d](e44d81d))
* **deps:** bump actions/checkout from 3 to 4 ([#1226](#1226)) ([7d5242c](7d5242c))
* **deps:** bump step-security/harden-runner from 2.7.0 to 2.9.0 ([#1225](#1225)) ([76755e1](76755e1))
* **examples:** Ensure bun examples have updated dependencies ([#1213](#1213)) ([e766029](e766029))
* Remove Dependencies section from release notes ([#1211](#1211)) ([1708f6a](1708f6a))
</details>

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants