                 continue
             }
 
-            guard let parsedURL = URL(string: url) else {
-                throw StringError("invalid url \(url)")
-            }
             let archivePath = parentDirectory.appending(component: parsedURL.lastPathComponent)
 
+            group.enter()
             didDownloadAnyArtifact = true
             downloader.downloadFile(
                 at: parsedURL,

                        guard archiveChecksum == checksum else {
                            tempDiagnostics.emit(.artifactInvalidChecksum(targetName: artifact.targetName, expectedChecksum: checksum, actualChecksum: archiveChecksum))
                            tempDiagnostics.wrap { try self.fileSystem.removeFileTree(archivePath) }
                            group.leave()
                            return
                        }

                        self.archiver.extract(from: archivePath, to: parentDirectory, completion: { extractResult in
                            switch extractResult {
                            case .success:
                                if let expectedPath = self.path(for: artifact), !self.fileSystem.isDirectory(expectedPath) {
                                    tempDiagnostics.emit(.artifactNotFound(targetName: artifact.targetName, artifactName: expectedPath.basename))
                                }
                                break
                            case .failure(let error):
                                let reason = (error as? LocalizedError)?.errorDescription ?? error.localizedDescription
                                tempDiagnostics.emit(.artifactFailedExtraction(targetName: artifact.targetName, reason: reason))
                            }

                            tempDiagnostics.wrap { try self.fileSystem.removeFileTree(archivePath) }
                            group.leave()
                        })
                    case .failure(let error):
                        let reason = error.errorDescription ?? error.localizedDescription
                        tempDiagnostics.emit(.artifactFailedDownload(targetName: artifact.targetName, reason: reason))
                        group.leave()
                    }
                })
        }

        #endif
        for artifact in artifacts {
            group.enter()
            defer { group.leave() }

            guard case .remote(let url, let checksum, _) = artifact.source, let destination = path(for: artifact) else {
                throw InternalError("Can't download local artifact")
            }

            guard let parsedURL = URL(string: url) else {
                throw StringError("invalid url \(url)")
            }

            let parentDirectory = destination.parentDirectory
