Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Restoring state docs clarification

オープン
#467 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
node.js, typescript
領域
documentation

調査の方向性

まず、ドキュメントにある createActor の snapshot の例を、報告されている getPersistedSnapshot の形および TypeScript とランタイムのエラーと比較します。スタックトレースは StateMachine.restoreSnapshot と src/oncocare/oncocare.service.ts:506 の呼び出し元を指しています。完了の条件は、ドキュメントがサポートされている restore の形を正確に説明し、例でこれらのエラーが発生しなくなることです。

索引モデルが issue の本文から書いたものです。

説明

Hi,

I'm trying to use a state machine in NodeJS.
I init the state machine. On server up, I'd like to hydrate the actor with existing data.
There's a typescript error and a runtime error if I override it.
The snapshot below is the same as getPersistedSnapshot. Is there a change in the restoring code that differs from documentation?

const stateMachine = setup({
    types: {...},
}).createMachine({
    context: ({ input }) => (...),
    id: 'state-machine',
    initial: 'incomplete,
    on: {...},
    states: {...}
});

const actor = createActor(stateMachine, {
    snapshot: {
        status: 'active',
        value: 'progress',
        context: {...},
    },
});

Typescript error:

Object literal may only specify known properties, and 'value' does not exist in type '{ status: "active"; output: undefined; error: undefined; }'.

Runtime error:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at StateMachine.restoreSnapshot (/server/node_modules/xstate/dist/xstate.cjs.js:520:12)
    at Actor._initState (/server/node_modules/xstate/dist/raise-5872b9e8.cjs.js:599:81)
    at new Actor (/server/node_modules/xstate/dist/raise-5872b9e8.cjs.js:592:10)
    at createActor (/server/node_modules/xstate/dist/raise-5872b9e8.cjs.js:1085:10)
    at setStateMachineStateForPerson (/server/src/oncocare/oncocare.service.ts:506:58)
    at OncocareService.auditStateMachine (/server/src/oncocare/oncocare.service.ts:115:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async OncocareService.onApplicationBootstrap (/server/src/oncocare/oncocare.service.ts:86:9)
    at async Promise.all (index 0)
主要言語
MDX
スター
38
フォーク
94
平均マージ
14時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

statelyai/docs のほかの issue

statelyai/docs の issue をすべて見る

似ている issue

Documentation の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。