Skip to content

Commit 54cc54d

Browse files
committed
fix currently_loading_uris going out of sync on error
1 parent 867a7a5 commit 54cc54d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/DocumentStore.zig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,11 @@ pub fn getOrLoadHandle(store: *DocumentStore, uri: Uri) ?*Handle {
701701
}
702702
}
703703

704+
defer {
705+
std.debug.assert(store.currently_loading_uris.swapRemove(uri));
706+
store.wait_for_currently_loading_uri.broadcast();
707+
}
708+
704709
const file_contents = store.readUri(uri) orelse return null;
705710
return store.createAndStoreDocument(uri, file_contents, false) catch |err| {
706711
log.err("failed to store document '{s}': {}", .{ uri, err });
@@ -1405,10 +1410,6 @@ fn createAndStoreDocument(
14051410
}
14061411
errdefer comptime unreachable; // would double free `text` on error
14071412

1408-
if (self.currently_loading_uris.swapRemove(uri)) {
1409-
self.wait_for_currently_loading_uri.broadcast();
1410-
}
1411-
14121413
return gop.value_ptr.*;
14131414
}
14141415

0 commit comments

Comments
 (0)