Fix error message propagation on plugin call failure (#12632)

# Description

This should fix the sometimes failing wrong version test for
stress_internals.

The plugin interface state stores an error if some kind of critical
error happened, and this error should be propagated to any future
operations on the interface, but this wasn't being propagated to plugin
calls that were already waiting.

During plugin registration, the wrong version error needs to be received
as a response to the `get_signature()` to show up properly, but this
would only happen if `get_signature()` started after the `Hello` was
already received and processed. That would be a race condition, which
this commit solves.

cc @sholderbach - this should fix the CI issue

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`
This commit is contained in:
Devyn Cairns 2024-04-23 15:30:51 -07:00 committed by GitHub
parent eec8645b9c
commit c9bc0c7d3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -817,11 +817,16 @@ impl PluginInterface {
}
}
}
// If we fail to get a response
// If we fail to get a response, check for an error in the state first, and return it if
// set. This is probably a much more helpful error than 'failed to receive response'
if let Some(error) = self.state.error.get() {
Err(error.clone())
} else {
Err(ShellError::PluginFailedToDecode {
msg: "Failed to receive response to plugin call".into(),
})
}
}
/// Handle an engine call and write the response.
fn handle_engine_call(