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: introduces X-Request-ID header to more easily identify retried requests #678

Merged
merged 4 commits into from
Jan 20, 2023

Conversation

krpeacock
Copy link
Contributor

Description

During the SNS-1 launch retrospective, we identified the difficulty in identifying retried requests as a pain point.

Adding a unique request id header (using the standard key, despite the similarity to the Request ID specified for checking the status of updates in the Internet Computer Specification

Fixes # SDK-880

How Has This Been Tested?

new unit tests

Checklist:

  • My changes follow the guidelines in CONTRIBUTING.md.
  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@krpeacock krpeacock requested a review from a team as a code owner January 20, 2023 00:01
@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2023

size-limit report 📦

Path Size
@dfinity/agent 89.94 KB (+0.07% 🔺)
@dfinity/candid 15.46 KB (0%)
@dfinity/principal 6.77 KB (0%)
@dfinity/auth-client 95.46 KB (+0.01% 🔺)
@dfinity/assets 92.07 KB (+0.01% 🔺)
@dfinity/identity 92.35 KB (+0.01% 🔺)
@dfinity/identity-secp256k1 230.06 KB (+0.04% 🔺)

krpeacock and others added 3 commits January 20, 2023 09:52
Co-authored-by: Eric Swanson <64809312+ericswanson-dfinity@users.noreply.github.com>
Copy link
Contributor

@dfx-json dfx-json 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, but left one comment on the use of btoa

},
body: cbor.encode(expectedRequest),
});
const call1 = calls[0][0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const call1 = calls[0][0];
const [call1, call2] = calls[0]

@@ -293,10 +293,10 @@ export class HttpAgent implements Agent {
request: {
body: null,
method: 'POST',
headers: {
headers: new Headers({
'Content-Type': 'application/cbor',
...(this._credentials ? { Authorization: 'Basic ' + btoa(this._credentials) } : {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

btoa is deprecated in node. would this ever run in a node context? if it were, better to detect the environment and use Buffer instead

if (isBrowserEnv()) {
  window.btoa(this._credentials);
}

if (isNodeEnv()) {
  Buffer.from(this._credentials).toString('base64')
}

@krpeacock krpeacock merged commit dcc4ea2 into main Jan 20, 2023
@krpeacock krpeacock deleted the SDK-880-header-nonce branch January 20, 2023 22:51
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.

None yet

3 participants