Skip to content

Commit 28dd3ce

Browse files
authoredNov 20, 2024··
fix: server island hydration (#12444)
1 parent ab0580b commit 28dd3ce

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed
 

‎.changeset/olive-garlics-marry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes an issue where a server island hydration script might fail case the island ID misses from the DOM.

‎packages/astro/src/runtime/server/render/server-islands.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ let response = await fetch('${serverIslandUrl}', {
8181
method: 'POST',
8282
body: JSON.stringify(data),
8383
});
84-
85-
if(response.status === 200 && response.headers.get('content-type') === 'text/html') {
84+
if (script) {
85+
if(response.status === 200 && response.headers.get('content-type') === 'text/html') {
8686
let html = await response.text();
8787
8888
// Swap!
@@ -97,6 +97,7 @@ if(response.status === 200 && response.headers.get('content-type') === 'text/htm
9797
script.before(frag);
9898
}
9999
script.remove();
100+
}
100101
</script>`);
101102
},
102103
};

0 commit comments

Comments
 (0)
Please sign in to comment.