Skip to Content
Grist Widgets

Errors and alerts

Where a widget's problems show: the screens before it renders, the alerts above it, a failed call, a cell that doesn't fit, and a widget that stops working.

A widget mounted with mountGristWidget() shows most problems on its own. This page says where each one appears, and what your code does about it.

Before the widget renders

Until the widget can work, a screen takes its place:

ScreenWhenWhat fixes it
Connecting to GristGrist hasn't answered yetNothing: it passes
Open inside GristThe page isn't in a Grist custom widget, or Grist's plugin API didn't loadOpening it in a Grist document
More access neededGrist granted less than the declaration's requiredAccessThe person accepts, or sets the level in the custom widget panel
Something went wrongGrist refused or didn't answer the connection (30 s)The retry button, which connects again
Map your columnsA required declared column isn't mappedThe person maps it in the panel

Your component never renders in these states: it can assume it is connected, with the access it asked for and its required columns mapped.

Alerts above the widget

While the widget runs, what needs the person's attention shows above it:

KindWhen
action-errorA write failed, with Grist's message and "Report a problem" when the declaration has a reportUrl
access-insufficientA read or write needed more access than granted
column-mapping, mapping-pendingA required column lost its mapping, or Grist hasn't sent the mappings yet
map-back-skipA write skipped a name mapped to several columns
cell-issuesA mapped cell doesn't fit its declared type
section-not-linked, source-not-wiredThe widget declares requiredLinking and its section isn't linked that way (Widget linking)
read-onlyThe document is open read-only and the widget writes

To turn a kind off, list it in the declaration:

export const widget = defineGristWidget({
  requiredAccess: "read table",
  suppressAlerts: ["cell-issues"],
})

A failed call

Every call that reaches Grist returns a promise that rejects with Grist's error. Writes also set w.actionStatus to "error" and w.actionError to the message, until the next write:

import { defineGristWidget } from "grist-widget-sdk"

export const widget = defineGristWidget({
  requiredAccess: "full",
  columns: [{ name: "Done", type: "Bool" }],
})

export function Save() {
  const w = widget.useGrist()
  return (
    <button disabled={w.actionStatus === "running"} onClick={() => w.updateRecord({ Done: true })}>
      {w.actionStatus === "error" ? `Try again (${w.actionError})` : "Mark done"}
    </button>
  )
}

A write nobody awaits, as here, logs nothing more: the alert already says it failed. Await it (and catch) when the widget does something next.

A cell that doesn't fit

In the mapped records, a cell that doesn't match its declared type, a formula error included, is null, and w.cellIssues lists which and why: the row, the column, the value and a message. The cell-issues alert shows the count. See Typed reads.

Outside the mapped records, a formula error comes in the form of what was read. In w.record and w.records, Grist sends it decoded, a RaisedException: check the cell with checkGristCell(type, value, { encoded: false }). In fetchRows(tableId), Grist's stored form, it is ["E", name, …]: isGristCellError(value) tests for that form only.

A widget that stops working

When the widget throws while rendering, "The widget stopped working" replaces it, with a button that reloads it and, with a reportUrl in the declaration, a "Report a problem" link (When something goes wrong). The error stays uncaught: it shows in the browser's console, and a renderWithGrist test of a widget that throws fails. A part of your widget that should fail on its own, without taking the rest with it, gets an error boundary of yours around it.

On this page