From 359ea5bedf29e1ef0b8042c357a73c2e38bbc1a0 Mon Sep 17 00:00:00 2001 From: James Graham Date: Wed, 4 Jan 2023 16:39:49 +0000 Subject: [PATCH] Fix returning null from commands We want returning null to map onto an empty result. We could do this explicitly per command, but it's less verbose to just allow null at the top level. --- index.bs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.bs b/index.bs index be9554468..57317917b 100644 --- a/index.bs +++ b/index.bs @@ -394,8 +394,12 @@ Each [=command=] is defined by: - A result type, which is defined by a [=local end definition=] fragment. - A set of [=remote end steps=] which define the actions to take for a command - given a [=BiDi session=] and [=command parameters=] and return an - instance of the command [=result type=]. + given a [=BiDi session=] and [=command parameters=]. If the command runs to + completion these steps return [=success=] with either a [=map=] matching the + command [=result type=] production or with null to indicate an + EmptyResult. If the command does not run to completion these + steps return [=error=] with the [=error code=] that will be reported to the + user. A command that can run without an active session is a static command. Commands are not static commands unless stated in their @@ -797,6 +801,8 @@ To handle an incoming message given a [=WebSocket connection=] 1. Let |value| be |result|'s data. + 1. If |value| is null, set |value| to an empty map. + 1. Assert: |value| matches the definition for the [=result type=] corresponding to the command with [=command name=] |method|. @@ -4917,7 +4923,7 @@ The [=remote end steps=] given |session| and |command parameters| are: 1. Remove |script| from |preload script map|. -1. Return null +1. Return [=success=] with data null