(fix): broken connections
Some checks failed
CI / checks (push) Failing after 5m37s

This commit is contained in:
Alois 2026-07-27 21:37:41 +02:00
commit 10c862de59
Signed by: alois
SSH key fingerprint: SHA256:GBzT2DXvAuGV9XIV5W3WrzVpjU54FThmxHXdbz95J24
3 changed files with 15 additions and 7 deletions

View file

@ -289,7 +289,7 @@ impl DataValue {
pub fn as_number(&self) -> Option<i128> {
match self {
DataValue::SignedNumber(n) => Some(*n),
DataValue::UnsignedNumber(n) => Some(*n as i128),
DataValue::UnsignedNumber(n) => i128::try_from(*n).ok(),
_ => None,
}
}
@ -1232,6 +1232,18 @@ mod tests {
Ok(())
}
#[test]
fn unsigned_number_conversion_rejects_i128_overflow() {
assert_eq!(
DataValue::UnsignedNumber(i128::MAX as u128).as_number(),
Some(i128::MAX)
);
assert_eq!(
DataValue::UnsignedNumber(i128::MAX as u128 + 1).as_number(),
None
);
}
#[test]
fn test_empty_container_and_array_have_distinct_framing() {
let container = DataValue::Container(vec![])

View file

@ -1,6 +1,6 @@
{
"name": "mtp",
"version": "0.2.0",
"version": "0.2.1",
"description": "MTP TypeScript SDK",
"type": "module",
"packageManager": "pnpm@11.8.0",

View file

@ -450,11 +450,7 @@ export function mtp(options: MTPVitePluginOptions): VitePlugin {
rebuildTimer = null;
void (async () => {
try {
await buildIfNeeded(state, true);
server.moduleGraph.invalidateAll();
if (server.ws) {
server.ws.send({ type: "full-reload" });
}
await server.restart();
} catch (error) {
server.config.logger.error(
error instanceof Error ? error.message : String(error),