fix: add exception handling to hermes-utils.rb (#54411)

Summary:
While working on the React Native macOS upgrade, I ran into this error while fetching hermes during `pod install`

```
Fetching podspec for `hermes-engine` from `../react-native/sdks/hermes-engine/hermes-engine.podspec`
[!] Failed to load 'hermes-engine' podspec:
[!] Invalid `hermes-engine.podspec` file: SSL_connect returned=1 errno=0 peeraddr=52.41.8.25:443 state=error: certificate verify failed (unable to get certificate CRL).

 #  from /Users/sanajmi/Developer/react-native-macos/packages/react-native/sdks/hermes-engine/hermes-engine.podspec:26
```

It seemed this simply came from an exception in `nightly_tarball_url`, which would stop the process. This change adds a fallback so that `pod install` can continue.

bypass-github-export-checks

## Changelog:

[INTERNAL] [FIXED] - add exception handling to hermes-utils.rb

Pull Request resolved: https://github.com/facebook/react-native/pull/54411

Test Plan: CI should pass

Reviewed By: cipolleschi

Differential Revision: D86225597

Pulled By: sbuggay

fbshipit-source-id: 3988dd5fdf199b719b9946234f865b2a4de389f8
This commit is contained in:
Saad Najmi authored and meta-codesync[bot] committed 2025-11-10 23:17:35 -08:00
1 parent ef3a85854a
commit 17d184cbab
1 file changed
+13 -9
@@ -256,16 +256,20 @@ def nightly_tarball_url(version)
xml_url = "https://central.sonatype.com/repository/maven-snapshots/#{namespace}/#{artifact_coordinate}/#{version}-SNAPSHOT/maven-metadata.xml"
response = Net::HTTP.get_response(URI(xml_url))
if response.is_a?(Net::HTTPSuccess)
xml = REXML::Document.new(response.body)
timestamp = xml.elements['metadata/versioning/snapshot/timestamp'].text
build_number = xml.elements['metadata/versioning/snapshot/buildNumber'].text
full_version = "#{version}-#{timestamp}-#{build_number}"
final_url = "https://central.sonatype.com/repository/maven-snapshots/#{namespace}/#{artifact_coordinate}/#{version}-SNAPSHOT/#{artifact_coordinate}-#{full_version}-#{artifact_name}"
begin
response = Net::HTTP.get_response(URI(xml_url))
if response.is_a?(Net::HTTPSuccess)
xml = REXML::Document.new(response.body)
timestamp = xml.elements['metadata/versioning/snapshot/timestamp'].text
build_number = xml.elements['metadata/versioning/snapshot/buildNumber'].text
full_version = "#{version}-#{timestamp}-#{build_number}"
final_url = "https://central.sonatype.com/repository/maven-snapshots/#{namespace}/#{artifact_coordinate}/#{version}-SNAPSHOT/#{artifact_coordinate}-#{full_version}-#{artifact_name}"
return final_url
else
return final_url
else
return ""
end
rescue => e
return ""
end
end