Skip to content
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: Invalid type in JSON write (_SwiftValue) #56

Open
MathisDetourbet opened this issue Aug 5, 2024 · 3 comments
Open

Crash: Invalid type in JSON write (_SwiftValue) #56

MathisDetourbet opened this issue Aug 5, 2024 · 3 comments

Comments

@MathisDetourbet
Copy link

MathisDetourbet commented Aug 5, 2024

I received some crashes for few users for 2 weeks now. The file where the crash occurs is: ExperimentClient.swift line 482

Here is the stacktrace:

NSInvalidArgumentException: Invalid type in JSON write (__SwiftValue)

0  CoreFoundation +0x9408          ___exceptionPreprocess
1  libobjc.A.dylib +0x15c24        _objc_exception_throw
2  Foundation +0x2c6a4             __writeJSONValue
3  Foundation +0xbb2e4             ____writeJSONObject_block_invoke
4  libswiftCore.dylib +0x2ae5b4    specialized _SwiftDeferredNSDictionary.enumerateKeysAndObjects(options:using:)
5  libswiftCore.dylib +0x9a190     @objc _SwiftDeferredNSDictionary.enumerateKeysAndObjects(options:using:)
6  Foundation +0x265e0             __writeJSONObject
7  Foundation +0xbb2e4             ____writeJSONObject_block_invoke
8  libswiftCore.dylib +0x2ae5b4    specialized _SwiftDeferredNSDictionary.enumerateKeysAndObjects(options:using:)
9  libswiftCore.dylib +0x9a190     @objc _SwiftDeferredNSDictionary.enumerateKeysAndObjects(options:using:)
10 Foundation +0x265e0             __writeJSONObject
11 Foundation +0x4d358             -[_NSJSONWriter dataWithRootObject:options:]
12 Foundation +0x4cdd0             +[NSJSONSerialization dataWithJSONObject:options:error:]
13 Shorts +0x811c60                specialized DefaultExperimentClient.doFetch(user:timeoutMillis:options:completion:) (ExperimentClient.swift:482:56)
14 Shorts +0x80bc20                specialized DefaultExperimentClient.doFetch(user:timeoutMillis:options:completion:) (<compiler-generated>)
15 Shorts +0x80b208                thunk for @escaping @callee_guaranteed @Sendable () -> ()
16 libdispatch.dylib +0x637a4      __dispatch_call_block_and_release
17 libdispatch.dylib +0x6477c      __dispatch_client_callout
18 libdispatch.dylib +0x3f6f8      __dispatch_lane_serial_drain$VARIANT$armv81
19 libdispatch.dylib +0x401ac      __dispatch_lane_invoke$VARIANT$armv81
20 libdispatch.dylib +0x49f10      __dispatch_workloop_worker_thread
21 libsystem_pthread.dylib +0x1bcc __pthread_wqthread
22 libsystem_pthread.dylib +0x171c _start_wqthread

Do you have an idea why I get it?

@tyiuhc
Copy link
Collaborator

tyiuhc commented Aug 5, 2024

Hi @MathisDetourbet, many thanks for raising this issue. It seems that there is an error with the JSON serialization of the user object passed into doFetch. It would be useful for us to know what types are contained within this user object.

@MathisDetourbet
Copy link
Author

MathisDetourbet commented Aug 5, 2024

Thanks for your reactive response. What is the best way to collect it? Since it happens to some users in production so I don't know how to reproduce the issue yet.

@tyiuhc
Copy link
Collaborator

tyiuhc commented Aug 5, 2024

The best way may be to 1. manually inspect the code that calls doFetch and how the user object is constructed, 2. add logging of the user object upon error. If the SDK is configured to be in debug mode, you should also be able to see the user object from this line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants