Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions scenarios/synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

from scenarios.helpers import info, run_cmd, sh

SYNAPSE_SDK_REPO = "https://github.com/FilOzone/synapse-sdk/"
SYNAPSE_SDK_REPO = os.environ.get(
"SYNAPSE_SDK_REPO", "https://github.com/FilOzone/synapse-sdk/"
)
SYNAPSE_SDK_REF = os.environ.get("SYNAPSE_SDK_REF", "synapse-sdk-v1.0.1")


def clone_and_build(tmp_dir: Path) -> Path | None:
Expand All @@ -17,7 +20,9 @@ def clone_and_build(tmp_dir: Path) -> Path | None:
):
return None
if not run_cmd(
["git", "checkout", "master"], cwd=str(sdk_dir), label="checkout master HEAD"
["git", "checkout", SYNAPSE_SDK_REF],
cwd=str(sdk_dir),
label=f"checkout {SYNAPSE_SDK_REF}",
):
return None
sdk_commit = sh(f"git -C {sdk_dir} rev-parse HEAD")
Expand Down
22 changes: 10 additions & 12 deletions scenarios/test_multi_copy_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
RAND_FILE_NAME = "random_file"
RAND_FILE_SIZE = 20 * 1024 * 1024
RAND_FILE_SEED = 42
FILECOIN_PIN_VERSION = "0.23.2"
ADD_DEADLINE_SECS = 240
ADD_INTERVAL_SECS = 10
ADD_ATTEMPT_TIMEOUT_SECS = 180
Expand Down Expand Up @@ -74,17 +75,14 @@ def output_text(value) -> str:


def patch_synapse_core_streaming_upload(npm_dir: Path) -> bool:
"""Strip Content-Length from @filoz/synapse-core's streaming upload headers.
"""Strip legacy Content-Length from @filoz/synapse-core streaming uploads.

synapse-core (as of 0.4.1, which filecoin-pin 0.20.1 resolves to) sets a
Content-Length header on a body that flows through a streaming Transform.
Node/undici rejects that as 'invalid content-length header', which
filecoin-pin surfaces as
Older synapse-core builds set a Content-Length header on a body that flows
through a streaming Transform. Node/undici rejects that as
'invalid content-length header', which filecoin-pin surfaces as
'StorageContext store failed: Failed to store piece on service provider -
Network request failed'.

TODO: drop this patch once filecoin-pin pins a synapse-core release that
omits Content-Length on streaming bodies (track upstream in FilOzone/synapse-sdk).
Network request failed'. Newer builds only set Content-Length for the
non-streaming Blob fallback, so this helper is intentionally a no-op there.

Returns True when the target file is in the desired state (whether or not
a change was applied). Returns False only when the file is missing.
Expand Down Expand Up @@ -112,8 +110,8 @@ def patch_synapse_core_streaming_upload(npm_dir: Path) -> bool:
)
else:
info(
"@filoz/synapse-core streaming upload already free of "
"Content-Length header; no patch needed"
"@filoz/synapse-core streaming upload has no legacy "
"Content-Length header pattern; no patch needed"
)
return True

Expand Down Expand Up @@ -246,7 +244,7 @@ def run():
"pkg",
"set",
"type=module",
"dependencies.filecoin-pin=0.20.1",
f"dependencies.filecoin-pin={FILECOIN_PIN_VERSION}",
"dependencies.multiformats=13.4.2",
],
label="pin filecoin-pin dependencies",
Expand Down
Loading