Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FirebaseStorage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Unreleased
- [fixed] Fixed an issue where `putFile` could fail on the iOS Simulator with `POSIX errno 40`
(`EMSGSIZE`) due to a QUIC bug in background sessions, and improved error formatting
for `NSPOSIXErrorDomain` errors. (#16351)
- [fixed] Fixed a race condition in Storage task cancellation and improved Swift 6 strict
concurrency compliance for `StorageTask`. (#16353)
- [fixed] Fixed a crash that could occur when parsing malformed `gs://` URLs, and improved
Expand Down
5 changes: 5 additions & 0 deletions FirebaseStorage/Sources/Internal/StorageFetcherService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ actor StorageFetcherService {
if let _fetcherService {
_fetcherService.testBlock = testBlock
}
for (_, bucketMap) in fetcherServiceMap {
for (_, fetcherService) in bucketMap {
fetcherService.testBlock = testBlock
}
}
Comment thread
paulb777 marked this conversation as resolved.
Outdated
}

private var testBlock: GTMSessionFetcherTestBlock?
Expand Down
14 changes: 11 additions & 3 deletions FirebaseStorage/Sources/StorageError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,17 @@ public let StorageErrorDomain: String = "FIRStorageErrorDomain"
case 404: StorageError.objectNotFound(
object: ref.path.object ?? "<object-entity-internal-error>", serverError: errorDictionary
)
default: StorageError.unknown(
message: "Unexpected \(serverError.code) code from backend", serverError: errorDictionary
)
default:
if serverError.domain == NSPOSIXErrorDomain {
StorageError.unknown(
message: "POSIX errno \(serverError.code) (\(String(cString: strerror(Int32(truncatingIfNeeded: serverError.code)))))",
serverError: errorDictionary
)
Comment thread
paulb777 marked this conversation as resolved.
Outdated
} else {
StorageError.unknown(
message: "Unexpected \(serverError.code) code from backend", serverError: errorDictionary
)
}
}
return storageError as NSError
}
Expand Down
7 changes: 6 additions & 1 deletion FirebaseStorage/Sources/StorageUploadTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ import Foundation
uploadFetcher.uploadFileURL = fileURL
uploadFetcher.comment = "File UploadTask"

if !GULAppEnvironmentUtil.supportsBackgroundURLSessionUploads() {
#if targetEnvironment(simulator)
let supportsBackground = false
#else
let supportsBackground = GULAppEnvironmentUtil.supportsBackgroundURLSessionUploads()
#endif
Comment thread
paulb777 marked this conversation as resolved.
Comment thread
paulb777 marked this conversation as resolved.
if !supportsBackground {
uploadFetcher.useBackgroundSession = false
}
}
Expand Down
44 changes: 44 additions & 0 deletions FirebaseStorage/Tests/Integration/StoragePOSIXErrorTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

@testable import FirebaseStorage
import Foundation
#if COCOAPODS
import GTMSessionFetcher
#else
import GTMSessionFetcherCore
#endif
import XCTest

@available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 6.0, *)
class StoragePOSIXErrorTest: StorageIntegrationCommon {
func testPutFileWithPOSIXError40() async throws {
let ref = storage.reference(withPath: "ios/public/testPOSIX40")

let data = try XCTUnwrap("Hello".data(using: .utf8))
let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory())
let fileURL = tmpDirURL.appendingPathComponent(#function + "hello.txt")
try data.write(to: fileURL, options: .atomicWrite)
Comment thread
paulb777 marked this conversation as resolved.
defer {
Comment thread
ncooke3 marked this conversation as resolved.
Outdated
try? FileManager.default.removeItem(at: fileURL)
}

do {
let metadata = try await ref.putFileAsync(from: fileURL)
XCTAssertEqual(metadata.size, Int64(data.count))
} catch {
XCTFail("Unexpected failure: \(error)")
}
Comment thread
paulb777 marked this conversation as resolved.
Outdated
}
}
Comment thread
paulb777 marked this conversation as resolved.
Loading