wavetermdev/waveterm · error

error writing blockfile %q: %w

Error message

error writing blockfile %q: %w

What it means

Companion to the MakeFile failure: after successfully creating the blockfile, WFS.WriteFile fails to write the file's byte content. Block creation aborts and the deferred cleanup deletes the block and its file zone.

Source

Thrown at pkg/wcore/block.go:99

	if blockDef.Meta == nil || blockDef.Meta.GetString(waveobj.MetaKey_View, "") == "" {
		return nil, fmt.Errorf("no view provided for new block")
	}
	blockData, err := createBlockObj(ctx, tabId, blockDef, rtOpts)
	if err != nil {
		return nil, fmt.Errorf("error creating block: %w", err)
	}
	blockCreated = true
	newBlockOID = blockData.OID
	// upload the files if present
	if len(blockDef.Files) > 0 {
		for fileName, fileDef := range blockDef.Files {
			err := filestore.WFS.MakeFile(ctx, newBlockOID, fileName, fileDef.Meta, wshrpc.FileOpts{})
			if err != nil {
				return nil, fmt.Errorf("error making blockfile %q: %w", fileName, err)
			}
			err = filestore.WFS.WriteFile(ctx, newBlockOID, fileName, []byte(fileDef.Content))
			if err != nil {
				return nil, fmt.Errorf("error writing blockfile %q: %w", fileName, err)
			}
		}
	}
	if recordTelemetry {
		blockView := blockDef.Meta.GetString(waveobj.MetaKey_View, "")
		blockController := blockDef.Meta.GetString(waveobj.MetaKey_Controller, "")
		go recordBlockCreationTelemetry(blockView, blockController, false)
	}
	return blockData, nil
}

func recordBlockCreationTelemetry(blockView string, blockController string, subBlock bool) {
	defer func() {
		panichandler.PanicHandler("CreateBlock:telemetry", recover())
	}()
	if blockView == "" {
		return
	}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Inspect the wrapped inner error from WFS.WriteFile
  2. Free disk space / fix storage permissions and retry
  3. Reduce the size of inline file content in blockDef.Files, or write content via streaming after block creation

Example fix

// before
Files: map[string]*waveobj.BlockFile{"big.log": {Content: hugeString}}
// after
// create block without inline content, then stream:
filestore.WFS.WriteFile(ctx, blockOID, "big.log", contentBytes)
Defensive patterns

Strategy: try-catch

Validate before calling

if len(fileDef.Content) > maxInlineSize {
    return errors.New("inline blockfile content too large; write after creation")
}

Try / catch

block, err := wcore.CreateBlock(ctx, tabId, blockDef, rtOpts)
if err != nil && strings.Contains(err.Error(), "error writing blockfile") {
    // check disk/IO, optionally create block then stream content
}

Prevention

When it happens

Trigger: WFS.WriteFile fails for an entry in blockDef.Files: disk full, I/O error on the storage backend, or the file vanished between MakeFile and WriteFile.

Common situations: Large file content exceeding available disk; storage permission problems; concurrent deletion of the block zone during creation.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/54f5f42e49dee678. Report an issue: GitHub.