Skip to content

bug: durable: WithMaxEventDataBytes counts JSON bytes, but FileStore stores base64, so a passing payload is refused after the kernel moved #242

Open

Description

@joshua-temple

Module

durable

What happened

  • The fix(durable): journal WithEventData payloads for recovery #230 size check counts the event data's JSON bytes before the kernel runs.
  • FileStore stores the bytes base64-encoded (about 4/3 larger) in one journal line, capped at 16 MiB.
  • With a raised WithMaxEventDataBytes, a payload under the limit passes the check, the kernel transitions, then Append fails with ErrRecordTooLarge.
  • The live instance has moved, and the store has not.
  • The 8 MiB default is safe: 8 MiB base64-encodes to about 10.7 MiB.

Expected behavior

  • A payload that passes the size check is one the store can write.
  • Or: WithMaxEventDataBytes refuses a limit the store can't hold, or the check counts the stored size.

Reproduction

On main @ 494c78a, in package durable_test (uses the existing linearMachine, runCtx helpers):

func TestFileStore_EventDataUnderLimit_IsStored(t *testing.T) {
	ctx := context.Background()
	st, _ := durable.NewFileStore(t.TempDir())
	r := durable.NewRunner(linearMachine(), st,
		durable.WithMaxEventDataBytes[string, string, *runCtx](14<<20))
	h, _ := r.Start(ctx, "big", &runCtx{}, state.WithInitialState("idle"))
	payload := strings.Repeat("a", 13<<20) // 13 MiB JSON, about 17.3 MiB base64
	if _, err := h.Fire(ctx, "go", state.WithEventData(payload)); err != nil {
		// fails: ErrRecordTooLarge, and Current has already moved
		t.Fatalf("refused after the kernel ran (current=%q): %v",
			h.Instance().Snapshot().Current, err)
	}
}

Environment

  • Crucible module version: main @ 494c78a
  • Go version (go version): go1.27.3
  • OS / arch: darwin/arm64

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions