-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash Current context must not be nil
in recordSnapshot
#875
Comments
I should add that this feels like a sendable/concurrency bug upstream but I thought I'd raise it here first in case you have some ideas where to best report/address it. |
Oh, never mind. I just saw this is a duplicate of #822 and that I should be marking those tests |
The issue is slightly more complicated than a missing We had tests like the following: @MainActor
func test_documentation_routes_current() async throws {
...
try await app.test(.GET, "/owner/package/~/documentation/target") { @Sendable res in
...
assertSnapshot(of: body, as: .html, named: "index")
...
}
...
} and these were leading to crashes on when recording. The fix is to move the func test_documentation_routes_current() async throws {
...
try await app.test(.GET, "/owner/package/~/documentation/target") { @MainActor res in
...
assertSnapshot(of: body, as: .html, named: "index")
...
}
...
} |
Hey @finestructure, thanks for documenting this! We do have plans to overhaul the sendability of the library, and we even have an experimental async branch that we use on the Point-Free codebase. We just need to clean things up, and see if it's possible to do in a backwards compatible way. |
I mentioned this crash to @stephencelis a couple of weeks ago when we first saw it with Xcode 16b2 but it had "disappeared" when I revisited our tests with Xcode 16b3.
Turns out it didn't really disappear but the conditions to trigger it changed in our project (SPI-Server). The conditions in that project are now:
@Sendable
__XCODE_BUILT_PRODUCTS_DIR_PATHS
env variable check), not when the test are run viaswift test
NB: we see the crash also with Xcode 15.4 and it seems to be related to the
@Sendable
changes we introduced while making the project ready for Swift 6. Reverting to a non-sendable closure makes the snapshot write succeed.However, I've just set up a new project and it's much simpler to trigger the crash there: https://github.com/finestructure/snapshot-testing-crash
NB: This test crashes on both Xcode 15.4 and Xcode 16b3. The culprit seems to be the
async
attribute on the test. It does not crash without it:The text was updated successfully, but these errors were encountered: