Skip to content

Application is crashing on Storage errors #154

@grzegorzkrukowski

Description

@grzegorzkrukowski

Describe the bug

We are getting crash reports coming from the Segment library.
According to crash logs, it's related to problems with writing files by a Storage class.

The problem seems to be related to using some deprecated methods of FileHandler class, which are throwing uncatchable errors:

extension FileHandle {    
    /* The API below may throw exceptions and will be deprecated in a future version of the OS.
     Use their replacements instead. */
    
    @available(macOS, introduced: 10.0, deprecated: 100000)
    open func write(_ data: Data)

To Reproduce
Steps to reproduce the behavior:

  1. Try to send any Segment event when disc has no more space left

Expected behavior
The segment should not cause application crash.
Ideally, the library should allow us to read those errors so we can react to them.

Platform (please complete the following information):

  • Library Version in use: 1.3.1
  • Platform being tested: macOS
  • Integrations in use: Amplitude

Additional context
Here is the important part of the stack trace from a crash:

OS Version: macOS 12.5.1 (21G83)
Report Version: 104

Exception Type: EXC_CRASH (SIGABRT)
Crashed Thread: 0

Application Specific Information:
*** -[NSConcreteFileHandle writeData:]: No space left on device

Thread 0 Crashed:
0   CoreFoundation                  0x315d69194         __exceptionPreprocess
1   libobjc.A.dylib                 0x3158eae00         objc_exception_throw
2   Foundation                      0x317bef54c         _NSFileHandleRaiseOperationExceptionWhileReading
3   Foundation                      0x317ac0c40         -[NSConcreteFileHandle writeData:]
4   Raycast                         0x205295b54         Storage.storeEvent (Storage.swift:268)
5   Raycast                         0x20529509c         Storage.write<T> (Storage.swift:37)
6   Raycast                         0x205265178         thunk for closure
7   Raycast                         0x205265198         thunk for closure
8   libdispatch.dylib               0x3158481b0         _dispatch_client_callout
9   libdispatch.dylib               0x315857410         _dispatch_lane_barrier_sync_invoke_and_complete
10  Raycast                         0x20529433c         Storage.write<T> (Storage.swift:32)
11  Raycast                         0x205265984         SegmentDestination.queueEvent<T> (SegmentDestination.swift:99)
12  Raycast                         0x205265858         SegmentDestination.execute<T> (SegmentDestination.swift:78)
13  Raycast                         0x20523f670         [inlined] Mediator.execute<T> (Timeline.swift:78)
14  Raycast                         0x20523f670         [inlined] thunk for closure
15  Raycast                         0x20523f670         [inlined] Sequence.forEach
16  Raycast                         0x20523f670         Mediator.execute<T> (Timeline.swift:73)
17  Raycast                         0x20523aea8         [inlined] Timeline.applyPlugins<T> (Timeline.swift:49)
18  Raycast                         0x20523aea8         Timeline.process<T> (Timeline.swift:37)
19  Raycast                         0x205247d44         [inlined] Analytics.process<T> (Analytics.swift:47)
20  Raycast                         0x205247d44         Analytics.identify<T> (Events.swift:68)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions