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

Drop axios dependency #3177

Merged
merged 35 commits into from
Jan 6, 2025
Merged

Drop axios dependency #3177

merged 35 commits into from
Jan 6, 2025

Conversation

matthieusieben
Copy link
Contributor

No description provided.

@matthieusieben matthieusieben marked this pull request as draft December 4, 2024 09:08
Comment on lines 394 to 396
get proxyHeadersTimeout(): number {
return this.cfg.proxyHeadersTimeout ?? 10e3
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a headsup that this change in timeout was disruptive at least for the PDS use case. Maybe we should set both defaults to something less conservative, like 30s.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As it stands, this will only impact getBlob calls from the "blob-resolver". The current timeout there is actually 5 seconds (see bellow).

https://github.com/bluesky-social/atproto/blob/c72145dbeb2d67068bc28c00a13447e0d382d121/packages/bsky/src/api/blob-resolver.ts#L133C1-L133C59

Should I:

  1. Lower the timeout to match current behavior ?
  2. Increase to timeout to future proof (when these config become used for other PDS proxying purposes) ?
  3. Leave it like that?

Comment on lines 156 to 157
const disableSsrfProtection =
process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we just configure this option in those environments rather than infer it? Or base it on the value of debugMode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the definition of debugMode so that is is "opt-in" instead of defaulting to true. Added the ability to override the value by setting the BSKY_DISABLE_SSRF_PROTECTION env var.

Comment on lines 98 to 108
const url = await getBlobUrl(dataplane, did, cid)

const dispatcherOptions: Dispatcher.RequestOptions = {
method: 'GET',
origin: url.origin,
path: url.pathname + url.search,
headers: Object.fromEntries([
...getBlobHeaders(cfg, url),
['accept-encoding', acceptEncoding],
]),
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The implementation gets a little complicated in order to get everything streaming end-to-end. In case it simplifies the implementation here, this code isn't performance critical and not used in production. The primary use is to run a self-contained local dev environment which is suitable for UI work, without needing to run an additional service such as imgproxy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My primary goal was to re-use as much from blob-resolver as possible. The fact that the entire transformation logic is exposed from here kinda makes sense IMO. I understand that perf improvement here is not a goal.

@matthieusieben matthieusieben marked this pull request as ready for review December 5, 2024 16:29
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