Handle errors when stringifying component context in case there somehow is a cyclical reference which is unserialisable
This commit is contained in:
parent
97375d1a33
commit
428fdfcc0a
|
@ -87,8 +87,14 @@ const loadBudibase = async () => {
|
||||||
} else if (type === "request-context") {
|
} else if (type === "request-context") {
|
||||||
const { selectedComponentInstance } = get(componentStore)
|
const { selectedComponentInstance } = get(componentStore)
|
||||||
const context = selectedComponentInstance?.getDataContext()
|
const context = selectedComponentInstance?.getDataContext()
|
||||||
|
let stringifiedContext = null
|
||||||
|
try {
|
||||||
|
stringifiedContext = JSON.stringify(context)
|
||||||
|
} catch (error) {
|
||||||
|
// Ignore - invalid context
|
||||||
|
}
|
||||||
eventStore.actions.dispatchEvent("provide-context", {
|
eventStore.actions.dispatchEvent("provide-context", {
|
||||||
context: JSON.stringify(context),
|
context: stringifiedContext,
|
||||||
})
|
})
|
||||||
} else if (type === "hover-component") {
|
} else if (type === "hover-component") {
|
||||||
hoverStore.actions.hoverComponent(data)
|
hoverStore.actions.hoverComponent(data)
|
||||||
|
|
Loading…
Reference in New Issue