Skip to content

Commit cf66341

Browse files
committed
fix(richtext-lexical): ensure errors during slate => lexical migration are caught and do not halt migration progress
1 parent 9beaa28 commit cf66341

File tree

1 file changed

+29
-13
lines changed
  • packages/richtext-lexical/src/utilities/migrateSlateToLexical

1 file changed

+29
-13
lines changed

packages/richtext-lexical/src/utilities/migrateSlateToLexical/index.ts

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,20 @@ async function migrateGlobal({
6464
})
6565

6666
if (found) {
67-
await payload.updateGlobal({
68-
slug: global.slug,
69-
data: document,
70-
depth: 0,
71-
locale: locale || undefined,
72-
})
67+
try {
68+
await payload.updateGlobal({
69+
slug: global.slug,
70+
data: document,
71+
depth: 0,
72+
locale: locale || undefined,
73+
})
74+
// Catch it, because some errors were caused by the user previously (e.g. invalid relationships) and will throw an error now, even though they are not related to the migration
75+
} catch (e) {
76+
console.log('Error updating global', e, {
77+
id: document.id,
78+
slug: global.slug,
79+
})
80+
}
7381
}
7482
}
7583

@@ -136,13 +144,21 @@ async function migrateCollection({
136144
})
137145

138146
if (found) {
139-
await payload.update({
140-
id: document.id,
141-
collection: collection.slug,
142-
data: document,
143-
depth: 0,
144-
locale: locale || undefined,
145-
})
147+
try {
148+
await payload.update({
149+
id: document.id,
150+
collection: collection.slug,
151+
data: document,
152+
depth: 0,
153+
locale: locale || undefined,
154+
})
155+
// Catch it, because some errors were caused by the user previously (e.g. invalid relationships) and will throw an error now, even though they are not related to the migration
156+
} catch (e) {
157+
console.log('Error updating collection', e, {
158+
id: document.id,
159+
slug: collection.slug,
160+
})
161+
}
146162
}
147163
}
148164
page++

0 commit comments

Comments
 (0)