-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print HTTP routes in stable order #1469
Comments
Looks like this was introduced sometime between Spin 1.0 and 1.1. 1.0 appears to use the order of components in the |
Okay this is the weirdest thing. It looks like the randomness started when #1321 got merged. But that's all about the Wasm component model, not anything to do with how we store Spin component metadata and HTTP routes, so seems unlikely! @dicej I am sorry to bug you with what I worry is a false positive, but can you think of any way in which the CM work could have had this effect? |
We're using an |
Yes, this was introduced as part of my component work. The fix is pretty simple: diff --git a/crates/trigger/src/lib.rs b/crates/trigger/src/lib.rs
index 175d6f9..4023244 100644
--- a/crates/trigger/src/lib.rs
+++ b/crates/trigger/src/lib.rs
@@ -8,6 +8,7 @@ use std::{collections::HashMap, marker::PhantomData, path::PathBuf};
use anyhow::{anyhow, Context, Result};
pub use async_trait::async_trait;
+use indexmap::IndexMap;
use serde::de::DeserializeOwned;
use spin_app::{App, AppComponent, AppLoader, AppTrigger, Loader, OwnedApp};
@@ -194,7 +195,7 @@ impl<Executor: TriggerExecutor> TriggerAppEngine<Executor> {
})?,
))
})
- .collect::<Result<HashMap<_, _>>>()?;
+ .collect::<Result<IndexMap<_, _>>>()?;
let mut component_instance_pres = HashMap::default();
for component in app.borrowed().components() { PR coming shortly. |
@dicej Oh, awesome. Thank you! |
This regressed due to changes I made to `TriggerAppEngine::new` to support components. I used a `HashMap` without realizing the iteration order of triggers (and their configs) matters. Fixes fermyon#1469 Signed-off-by: Joel Dice <[email protected]>
This regressed due to changes I made to `TriggerAppEngine::new` to support components. I used a `HashMap` without realizing the iteration order of triggers (and their configs) matters. Fixes #1469 Signed-off-by: Joel Dice <[email protected]>
When Spin prints:
the order is currently random. This defeats muscle memory, and requires users to scan the whole list to find the one they're interested in. (You scoff? Try it on https://github.com/fermyon/developer/.)
The order should:
I have a feeling it used to be stable and the randomness is a regression - I only started noticing this on the docs site recently but I could be wrong!
The text was updated successfully, but these errors were encountered: