Skip to content

Notify Cider when connection is successful #2302

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

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dwds/debug_extension_mv3/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mv3_extension
publish_to: none
version: 2.1.0
version: 2.1.1
homepage: https://github.com/dart-lang/webdev
description: >-
A Chrome extension for Dart debugging.
Expand Down
5 changes: 5 additions & 0 deletions dwds/debug_extension_mv3/web/cider_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const _ciderDartMessageKey = 'CIDER_DART';
/// The types must match those defined by ChromeExtensionMessageType in the
/// Cider extension.
enum CiderMessageType {
connected,
error,
inspectorUrlResponse,
inspectorUrlRequest,
Expand Down Expand Up @@ -54,11 +55,14 @@ Port? _ciderPort;
/// URIs for Cider are set in the externally_connectable field in the manifest.
void handleCiderConnectRequest(Port port) {
if (port.name == _ciderPortName) {
debugLog('Received connect request from Cider', verbose: true);
_ciderPort = port;

port.onMessage.addListener(
allowInterop(_handleMessageFromCider),
);

sendMessageToCider(messageType: CiderMessageType.connected);
}
}

Expand Down Expand Up @@ -130,6 +134,7 @@ Future<void> _startDebugging({String? appId}) async {
final tabId = _tabId(appId);
// TODO(https://github.com/dart-lang/webdev/issues/2198): When debugging
// with Cider, disable debugging with DevTools.
debugLog('Attach debugger to Cider', verbose: true);
await attachDebugger(tabId, trigger: Trigger.cider);
}

Expand Down
4 changes: 3 additions & 1 deletion dwds/debug_extension_mv3/web/debug_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Future<void> attachDebugger(
forwardErrorsToCider: trigger == Trigger.cider,
);
if (!tabIsDebuggable) return;

debugLog('Attaching to tab $dartAppTabId', verbose: true);
_tabIdToTrigger[dartAppTabId] = trigger;
_registerDebugEventListeners();
chrome.debugger.attach(
Expand Down Expand Up @@ -357,6 +357,7 @@ Future<bool> _connectToDwds({
? WebSocketClient(WebSocketChannel.connect(uri))
: SseSocketClient(SseClient(uri.toString(), debugKey: 'DebugExtension'));
final trigger = _tabIdToTrigger[dartAppTabId];
debugLog('Connecting to DWDS...', verbose: true);
final debugSession = _DebugSession(
client: client,
appTabId: dartAppTabId,
Expand Down Expand Up @@ -418,6 +419,7 @@ void _routeDwdsEvent(String eventData, SocketClient client, int tabId) {
}
}
if (message.method == 'dwds.debugUri') {
debugLog('Sending debug URI to Cider ${message.params}', verbose: true);
sendMessageToCider(
messageType: CiderMessageType.startDebugResponse,
messageBody: message.params,
Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension_mv3/web/manifest_mv3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Dart Debug Extension",
"version": "2.1",
"version": "2.1.1",
"manifest_version": 3,
"devtools_page": "static_assets/devtools.html",
"action": {
Expand Down