Summary
DocumentDbContext.Dispose() disposes the StorageEngine without first flushing the Write-Ahead Log into the main data file. After disposal the .blite file may still have pending WAL records not merged into the main page file, making it fragile to copy, ship, or open cold on another machine.
Current behaviour
DocumentDbContext.Dispose() calls _storage?.Dispose() without calling CheckpointAsync() first. The StorageEngine already exposes CheckpointAsync() and it is used correctly in BLiteEngine and BLiteMigration, but not wired up on context disposal.
Expected behaviour
Either:
DocumentDbContext exposes a public CheckpointAsync() that delegates to _storage.CheckpointAsync(), so callers can flush before closing; OR
DisposeAsync() automatically checkpoints when there are no active transactions.
Option 1 is safer (no hidden async work in Dispose), but option 2 covers the common write-and-close use-case.
Workaround
Re-open the file with BLiteEngine immediately after disposing the context:
using (var db = new HelpDbContext(path))
await db.HelpChunks.InsertBulkAsync(chunks, transaction: null);
using var engine = new BLiteEngine(path);
await engine.CheckpointAsync();
Context
Discovered during a bulk-insert build tool where help.blite is generated once and shipped as an embedded asset. Without an explicit checkpoint the resulting file is not guaranteed to be fully self-contained.
Summary
DocumentDbContext.Dispose()disposes theStorageEnginewithout first flushing the Write-Ahead Log into the main data file. After disposal the.blitefile may still have pending WAL records not merged into the main page file, making it fragile to copy, ship, or open cold on another machine.Current behaviour
DocumentDbContext.Dispose()calls_storage?.Dispose()without callingCheckpointAsync()first. TheStorageEnginealready exposesCheckpointAsync()and it is used correctly inBLiteEngineandBLiteMigration, but not wired up on context disposal.Expected behaviour
Either:
DocumentDbContextexposes a publicCheckpointAsync()that delegates to_storage.CheckpointAsync(), so callers can flush before closing; ORDisposeAsync()automatically checkpoints when there are no active transactions.Option 1 is safer (no hidden async work in Dispose), but option 2 covers the common write-and-close use-case.
Workaround
Re-open the file with
BLiteEngineimmediately after disposing the context:Context
Discovered during a bulk-insert build tool where
help.bliteis generated once and shipped as an embedded asset. Without an explicit checkpoint the resulting file is not guaranteed to be fully self-contained.