fix(api): treat post opts as request options, not headers#1868
fix(api): treat post opts as request options, not headers#1868kinderjoypresents wants to merge 1 commit intoProjectOpenSea:mainfrom
Conversation
|
Hey @kinderjoypresents, thanks for the PR and your others! Before we consider merging, could you share a concrete scenario where you hit this bug? The current behavior has been stable, and while I understand the docs/implementation mismatch you're pointing out, the heuristic-based detection (looksLikeHeaders) adds complexity that could introduce subtle bugs of its own. If there's a real use case driving this, I'd prefer a simpler solution - either properly typing the options interface or just being explicit that the parameter only accepts headers. Let me know what problem you were trying to solve and we can discuss the right approach. |
Hey, thanks for the thoughtful feedback. A concrete scenario where I hit this: I needed to pass request-level options to the underlying fetch/HTTP layer (not headers). For example:
|
Add support for request-level options in post() method: - timeout: Set request timeout in milliseconds - signal: Pass AbortController signal for request cancellation This enables: - Abort/timeout control via AbortController (useful for CI, batch scripts) - Custom timeout settings per request The new RequestOptions interface is exported for SDK consumers. Closes the use case from #1868 with a clean, typed interface instead of heuristics. Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Thanks for explaining the use case! That makes sense - timeout/abort control and custom agents are legitimate request-level concerns. I've opened #1871 which adds a proper typed RequestOptions interface: await api.post('/path', body, headers, {
timeout: 5000, // timeout in ms
signal: controller.signal // AbortController support
});This addresses your timeout/abort use case with explicit typing instead of heuristics. The interface is also exported so SDK consumers can use it. For custom agent/proxy settings - those would need additional work since ethers.FetchRequest doesn't directly expose that. If that's important for your use case, let me know and we can explore options (might require a different approach like allowing a custom fetch implementation, but would prefer to stick to ethers for simplicity and relying on battle tested library than rolling our own). |
* feat(api): add request options for timeout and abort signal Add support for request-level options in post() method: - timeout: Set request timeout in milliseconds - signal: Pass AbortController signal for request cancellation This enables: - Abort/timeout control via AbortController (useful for CI, batch scripts) - Custom timeout settings per request The new RequestOptions interface is exported for SDK consumers. Closes the use case from #1868 with a clean, typed interface instead of heuristics. Co-Authored-By: Claude Opus 4.5 <[email protected]> * feat(api): add request options to get() method Extend RequestOptions support to get() for consistency with post(). Same timeout and abort signal options now available for GET requests. Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
Problem
OpenSeaAPI.post(apiPath, body, opts) documents opts as ConnectionInfo-like request options, but the internal _fetch previously treated the entire opts object as headers. This could accidentally send fields like timeout as HTTP headers.
Solution
Update _fetch to:
Tests