Skip to content

Commit 5d9b159

Browse files
Debug logging for writeProtected save-failure detection
Add console.warn at two points: - web-file-transfer.js _fetch: log method+path+status on any non-OK response, so we can see what the firmware actually sent back. - script.js saveFileContents catch block: log the relevant fields on the caught error (name/message/status/method/path/writeProtected), so we can see whether the heuristic in _fetch tagged it correctly. Temporary; remove once we've confirmed the field paths fire on real hardware. Cheap (warn-level, only runs on actual errors).
1 parent 702f8b8 commit 5d9b159

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎js/common/web-file-transfer.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ class FileTransferClient {
128128
err.status = response.status;
129129
err.method = (fetchOptions.method || "GET").toUpperCase();
130130
err.path = location;
131+
// DEBUG: leave this in until we're sure the writeProtected
132+
// detection is firing in the field. Cheap, runs only on
133+
// non-OK responses.
134+
console.warn("[web-file-transfer] non-OK response", {
135+
method: err.method,
136+
path: err.path,
137+
status: err.status,
138+
statusText: response.statusText,
139+
});
131140
// /fs/ PUT against a write-protected filesystem currently returns
132141
// 500 on shipped CircuitPython firmware. A fix is pending to
133142
// return 409 Conflict (matching DELETE / MOVE / mkdir-PUT in

‎js/script.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,14 @@ async function saveFileContents(path) {
594594
return false;
595595
} catch (e) {
596596
console.error(`write failed (attempt ${attempt} of ${MAX_SAVE_RETRIES})`, e, e.stack);
597+
console.warn("[saveFileContents] caught error fields", {
598+
name: e && e.name,
599+
message: e && e.message,
600+
status: e && e.status,
601+
method: e && e.method,
602+
path: e && e.path,
603+
writeProtected: e && e.writeProtected,
604+
});
597605
unchanged = Math.min(baseUnchanged, unchanged);
598606
// If the device cleanly told us the filesystem is held by
599607
// someone else (most commonly USB-MSC: the host has

0 commit comments

Comments
 (0)