GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Bug] 函数式 payload 触发 RTK "A non-serializable value was detected" 告警(form/updateState) · Issue #2 · codingapi/form-engine

[Bug] 函数式 payload 触发 RTK "A non-serializable value was detected" 告警(form/updateState) #2

New issue
Copy link
New issue
Copy link
Open
Open
[Bug] 函数式 payload 触发 RTK "A non-serializable value was detected" 告警(form/updateState)#2
Copy link

Description

@jaquanli
jaquanli
opened on Nov 8, 2026
Issue body actions

@coding-form/[email protected] + @reduxjs/[email protected],dev 环境下任何表单状态更新都会打印:

A non-serializable value was detected in an action, in the path: payload.
Value: (prevState)=>({ ...prevState, fields: ... })
{type: 'form/updateState', payload: ƒ}
根因:updateState 的 payload 类型明确允许函数(packages/form-engine/src/store/index.tsx:6:PayloadAction<Partial | ((prev: FormState) => Partial)>),reducer 也按函数分支处理(同文件 15-22 行),但 store 创建时只传了 reducer(同文件 30-34 行),RTK 默认的 serializableStateInvariant 把这个函数判为非法值 —— 库自己承诺的能力被库自己的中间件否定了。

由于 FormPresenter.hiddenFields(src/presenters/form-presenter.ts:23)、refreshFields(:56)、requiredFields(:88)以及 hooks/use-form-context.tsx 全部是函数式 dispatch,接入方即使不写任何业务代码也会刷屏告警,且每个 action 都要做深度可序列化扫描,字段联动多时存在开发期性能损耗。

复现:任意 change 事件里调用 instance.hiddenFields(true, ['some_field']),或业务侧调用 instance.presenter.dispatch((prev) => ({...prev, fields: ...}))。

建议修复(改动最小、零兼容风险):

ts
复制
export const formStore = configureStore({
reducer: { form: formSlice.reducer },
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({ serializableCheck: false }),
});
这是 RTK 官方对"有意使用非可序列化数据"的标准做法;immutableStateInvariant 可保留(只校验 state 的不可变更新,不受函数 payload 影响)。另建议 README 说明 dispatch 支持函数式 payload,并注明该 store 已关闭 serializableCheck,避免接入方误判。

临时绕过:下游用 pnpm patch 对 @coding-form/[email protected] 打了同样的补丁,上游修复后可移除。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.