fix(compile): error when cannot extract binary section (#28986)

We were silently failing on failure here.
This commit is contained in:
David Sherret 2025-04-21 11:21:37 -04:00 committed by GitHub
parent 5bee29223d
commit 104514b06d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 15 deletions

View file

@ -57,9 +57,9 @@ pub struct StandaloneData {
/// the bundle is executed. If not, this function exits with `Ok(None)`.
pub fn extract_standalone(
cli_args: Cow<Vec<OsString>>,
) -> Result<Option<StandaloneData>, AnyError> {
) -> Result<StandaloneData, AnyError> {
let Some(data) = libsui::find_section("d3n0l4nd") else {
return Ok(None);
bail!("Could not find standalone binary section.")
};
let root_path = {
@ -80,10 +80,7 @@ pub fn extract_standalone(
modules_store: remote_modules,
vfs_root_entries,
vfs_files_data,
} = match deserialize_binary_data_section(&root_url, data)? {
Some(data_section) => data_section,
None => return Ok(None),
};
} = deserialize_binary_data_section(&root_url, data)?;
let cli_args = cli_args.into_owned();
metadata.argv.reserve(cli_args.len() - 1);
@ -106,7 +103,7 @@ pub fn extract_standalone(
metadata.vfs_case_sensitivity,
))
};
Ok(Some(StandaloneData {
Ok(StandaloneData {
metadata,
modules: Arc::new(StandaloneModules {
modules: remote_modules,
@ -115,7 +112,7 @@ pub fn extract_standalone(
npm_snapshot,
root_path,
vfs,
}))
})
}
pub struct DeserializedDataSection {
@ -129,7 +126,7 @@ pub struct DeserializedDataSection {
pub fn deserialize_binary_data_section(
root_dir_url: &Url,
data: &'static [u8],
) -> Result<Option<DeserializedDataSection>, AnyError> {
) -> Result<DeserializedDataSection, AnyError> {
fn read_magic_bytes(input: &[u8]) -> Result<(&[u8], bool), AnyError> {
if input.len() < MAGIC_BYTES.len() {
bail!("Unexpected end of data. Could not find magic bytes.");
@ -143,7 +140,7 @@ pub fn deserialize_binary_data_section(
let (input, found) = read_magic_bytes(data)?;
if !found {
return Ok(None);
bail!("Did not find magic bytes.");
}
// 1. Metadata
@ -190,13 +187,13 @@ pub fn deserialize_binary_data_section(
remote_modules_store,
);
Ok(Some(DeserializedDataSection {
Ok(DeserializedDataSection {
metadata,
npm_snapshot,
modules_store,
vfs_root_entries,
vfs_files_data,
}))
})
}
struct SpecifierStore {

View file

@ -71,7 +71,7 @@ fn main() {
let standalone = extract_standalone(Cow::Owned(args));
let future = async move {
match standalone {
Ok(Some(data)) => {
Ok(data) => {
deno_runtime::deno_telemetry::init(
otel_runtime_config(),
data.metadata.otel_config.clone(),
@ -85,7 +85,6 @@ fn main() {
let exit_code = run::run(Arc::new(sys.clone()), sys, data).await?;
deno_runtime::exit(exit_code);
}
Ok(None) => Ok(()),
Err(err) => {
init_logging(None, None);
Err(err)
@ -93,7 +92,9 @@ fn main() {
}
};
unwrap_or_exit(create_and_run_current_thread_with_maybe_metrics(future));
unwrap_or_exit::<()>(create_and_run_current_thread_with_maybe_metrics(
future,
));
}
fn init_logging(