Sourcegraph extension API: use and build extensions that enhance reading and reviewing code in your existing tools. "The extension API you wish your code host had."
44
stars
2
forks
source link
chore: suppress connection error when disabling an extension #91
Previously, an unhandled promise rejection could occur when disabling a Sourcegraph extension. Here's a rough sequence of events that could trigger it:
The user disables an extension in the UI
The configuration gets updated with "foo-extension": false
sourcegraph-extension-api sends a request over JSON-RPC (which would eventually notify foo-extension of this configuration change)
Before the response comes back, e-c-c removes foo-extension from the list of active extensions and sourcegraph-extension-api unsubscribes the connection
The in-flight responses are rejected
The rejected promise turns into the console error we see
All I did was suppress the error, because this seems like a case that "shouldn't happen". It's kind of like we're sending SIGTERM to the extension but not waiting 500ms for the extension to exit.
A more involved solution could be: don't send a configuration update to an extension if the only change was the enablement state.
Another solution could be: separate the concepts of enablement state and configuration.
Previously, an unhandled promise rejection could occur when disabling a Sourcegraph extension. Here's a rough sequence of events that could trigger it:
"foo-extension": false
foo-extension
of this configuration change)foo-extension
from the list of active extensions and sourcegraph-extension-api unsubscribes the connectionAll I did was suppress the error, because this seems like a case that "shouldn't happen". It's kind of like we're sending
SIGTERM
to the extension but not waiting 500ms for the extension to exit.A more involved solution could be: don't send a configuration update to an extension if the only change was the enablement state.
Another solution could be: separate the concepts of enablement state and configuration.
See https://github.com/sourcegraph/sourcegraph/issues/373