fix: return errors instead of panicking in memory loader and v1 functions (#524)

* fix: return errors instead of panicking in memory loader and v1 functions

- MemoryLoader recovers from a poisoned lock. Previously a panic during
  one add() (e.g. a failing content conversion) made every later
  add/get/remove/keys call panic for the rest of the process
- v1 function node returns an error when its JS bootstrap fails instead
  of unwrapping. The 500ms interrupt budget starts before the runtime and
  bundled libraries load, so a slow or loaded host could interrupt the
  bootstrap and panic

* chore: bump setup-android to v3 in uniffi workflow

Only platform-tools is installed; Gradle fetches the platform and build tools the AAR build needs.
This commit is contained in:
stefan-gorules
2026-09-28 11:24:17 +02:00
committed by GitHub
parent adf7cdf44a
commit e095189dd6
3 changed files with 9 additions and 7 deletions
+3 -1
View File
@@ -744,8 +744,10 @@ jobs:
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v2
uses: android-actions/setup-android@v3
id: setup-android
with:
packages: 'platform-tools'
- name: Download Kotlin bindings
uses: actions/download-artifact@v4
+4 -4
View File
@@ -17,7 +17,7 @@ impl MemoryLoader {
K: Into<String>,
D: Into<DecisionContent>,
{
let mut mref = self.memory_refs.write().unwrap();
let mut mref = self.memory_refs.write().unwrap_or_else(|e| e.into_inner());
mref.insert(key.into(), Arc::new(content.into()));
}
@@ -25,7 +25,7 @@ impl MemoryLoader {
where
K: AsRef<str>,
{
let mref = self.memory_refs.read().unwrap();
let mref = self.memory_refs.read().unwrap_or_else(|e| e.into_inner());
mref.get(key.as_ref()).map(|r| r.clone())
}
@@ -33,7 +33,7 @@ impl MemoryLoader {
where
K: AsRef<str>,
{
let mut mref = self.memory_refs.write().unwrap();
let mut mref = self.memory_refs.write().unwrap_or_else(|e| e.into_inner());
mref.remove(key.as_ref()).is_some()
}
}
@@ -50,7 +50,7 @@ impl DecisionLoader for MemoryLoader {
}
fn keys(&self) -> Option<Vec<Arc<str>>> {
let mref = self.memory_refs.read().unwrap();
let mref = self.memory_refs.read().unwrap_or_else(|e| e.into_inner());
Some(mref.keys().map(|k| Arc::from(k.as_str())).collect())
}
+2 -2
View File
@@ -38,9 +38,9 @@ impl Script {
"main",
"import 'internals'; globalThis.now = Date.now();",
)
.unwrap()
.map_err(|e| map_js_error(&ctx, e))?
.finish::<()>()
.unwrap();
.map_err(|e| map_js_error(&ctx, e))?;
let _ = ctx
.globals()