SwiftData with inMemory storage promptly crashes with nw_socket_handle_socket_event

When my code tries to access a SwiftData model's relationship, my app promptly crashes with nw_socket_handle_socket_event [C1.1.1:2] Socket SO_ERROR 61 and no useful information. How do I go about debugging this?

I'm creating my modelContainer as inMemory, so I don't think this should be touching any SQLite DB:

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
        .modelContainer(
            for: SchemaV1.models,
            inMemory: true,
            isAutosaveEnabled: false,
            isUndoEnabled: false)
    }
}

I figured out my initial issue here. While I was fetching data and converting it to SwiftData, I had forgotten to insert it into SwiftData via context.insert(...). Doing this fixed this issue.

Now I have the exact same error in another part of my app after modifying data, so I guess SwiftData/CoreData just throws the same thing regardless of what issue it encounters.

SwiftData with inMemory storage promptly crashes with nw_socket_handle_socket_event
 
 
Q