@@ -258,13 +258,21 @@ export async function registerSiwxResource(
258258 description : description ?? undefined ,
259259 favicon : favicon ?? undefined ,
260260 ogImages :
261- og ?. ogImage ?. map ( image => ( {
262- url : image . url ,
263- height : image . height ,
264- width : image . width ,
265- title : og . ogTitle ,
266- description : og . ogDescription ,
267- } ) ) ?? [ ] ,
261+ og ?. ogImage ?. flatMap ( image => {
262+ try {
263+ return [
264+ {
265+ url : new URL ( image . url , origin ) . toString ( ) ,
266+ height : image . height ,
267+ width : image . width ,
268+ title : og . ogTitle ,
269+ description : og . ogDescription ,
270+ } ,
271+ ] ;
272+ } catch {
273+ return [ ] ;
274+ }
275+ } ) ?? [ ] ,
268276 } ) ;
269277 } catch ( err ) {
270278 console . error (
@@ -524,15 +532,31 @@ export const registerResource = async (
524532 description : description ?? undefined ,
525533 favicon : favicon ?? undefined ,
526534 ogImages :
527- og ?. ogImage ?. map ( image => ( {
528- url : image . url ,
529- height : image . height ,
530- width : image . width ,
531- title : og . ogTitle ,
532- description : og . ogDescription ,
533- } ) ) ?? [ ] ,
534- } ) . catch ( ( ) => {
535- // P2002 or other race — another call already upserted this origin.
535+ og ?. ogImage ?. flatMap ( image => {
536+ try {
537+ return [
538+ {
539+ url : new URL ( image . url , origin ) . toString ( ) ,
540+ height : image . height ,
541+ width : image . width ,
542+ title : og . ogTitle ,
543+ description : og . ogDescription ,
544+ } ,
545+ ] ;
546+ } catch {
547+ return [ ] ;
548+ }
549+ } ) ?? [ ] ,
550+ } ) . catch ( err => {
551+ // P2002: another concurrent call already upserted this origin — safe to ignore.
552+ // Log anything else so metadata failures aren't silent.
553+ const isP2002 =
554+ err instanceof Error &&
555+ 'code' in err &&
556+ ( err as { code : string } ) . code === 'P2002' ;
557+ if ( ! isP2002 ) {
558+ console . error ( '[registerResource] Origin metadata upsert failed:' , err ) ;
559+ }
536560 } ) ;
537561
538562 await upsertResourceResponse (
0 commit comments