Skip to content

Remove unused ExpressionCompilerService.handler code #1674

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
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
3 changes: 3 additions & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 15.0.1-dev
- Remove no longer used `ExpressionCompilerService.handler`.

## 15.0.0
- Port some `dwds` files to null safety.
- Fix failing `frontend_server_evaluate` tests.
Expand Down
58 changes: 1 addition & 57 deletions dwds/lib/src/services/expression_compiler_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import 'dart:isolate';

import 'package:async/async.dart';
import 'package:logging/logging.dart';
import 'package:shelf/shelf.dart';

import '../utilities/dart_uri.dart';
import '../utilities/sdk_configuration.dart';
import 'expression_compiler.dart';

Expand Down Expand Up @@ -218,16 +216,14 @@ class _Compiler {
///
/// Users need to stop the service by calling [stop].
class ExpressionCompilerService implements ExpressionCompiler {
final _logger = Logger('ExpressionCompilerService');
final _compiler = Completer<_Compiler>();
final String _address;
final FutureOr<int> _port;
final Handler _assetHandler;
final bool _verbose;

final SdkConfigurationProvider _sdkConfigurationProvider;

ExpressionCompilerService(this._address, this._port, this._assetHandler,
ExpressionCompilerService(this._address, this._port,
{bool verbose = false,
SdkConfigurationProvider? sdkConfigurationProvider})
: _verbose = verbose,
Expand Down Expand Up @@ -271,56 +267,4 @@ class ExpressionCompilerService implements ExpressionCompiler {
Future<void> stop() async {
if (_compiler.isCompleted) return (await _compiler.future).stop();
}

/// Handles resource requests from expression compiler worker.
///
/// Handles REST get requests of the form:
/// http://host:port/getResource?uri=<resource uri>
///
/// Where the resource uri can be a package Uri for a dart file
/// or a server path for a full dill file.
/// Translates given resource uri to a server path and redirects
/// the request to the asset handler.
FutureOr<Response> handler(Request request) async {
final uri = request.requestedUri.queryParameters['uri'];
try {
final query = request.requestedUri.path;
_logger.finest('request: ${request.method} ${request.requestedUri}');

if (query != '/getResource' || uri == null) {
return Response.notFound(uri);
}

if (!uri.endsWith('.dart') && !uri.endsWith('.dill')) {
return Response.notFound(uri);
}

var serverPath = uri;
if (uri.endsWith('.dart')) {
serverPath = DartUri(uri).serverPath;
}

_logger.finest('serverpath for $uri: $serverPath');

request = Request(
request.method,
Uri(
scheme: request.requestedUri.scheme,
host: request.requestedUri.host,
port: request.requestedUri.port,
path: serverPath,
),
protocolVersion: request.protocolVersion,
context: request.context,
headers: request.headers,
handlerPath: request.handlerPath,
encoding: request.encoding,
);

return await _assetHandler(request);
} catch (e, s) {
_logger.severe('Error loading $uri', e, s);
rethrow;
}
}
}
2 changes: 1 addition & 1 deletion dwds/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dwds/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dwds
# Every time this changes you need to run `dart run build_runner build`.
version: 15.0.0
version: 15.0.1-dev
description: >-
A service that proxies between the Chrome debug protocol and the Dart VM
service protocol.
Expand Down
7 changes: 2 additions & 5 deletions dwds/test/expression_compiler_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,12 @@ void main() async {
// start expression compilation service
Response assetHandler(request) =>
Response(200, body: File.fromUri(kernel).readAsBytesSync());
service = ExpressionCompilerService('localhost', port, assetHandler,
verbose: false);
service = ExpressionCompilerService('localhost', port, verbose: false);

await service.initialize(moduleFormat: 'amd');

// setup asset server
serveHttpRequests(
server, Cascade().add(service.handler).add(assetHandler).handler,
(e, s) {
serveHttpRequests(server, assetHandler, (e, s) {
logger.warning('Error serving requests', e, s);
});

Expand Down
1 change: 0 additions & 1 deletion dwds/test/fixtures/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ class TestContext {
ddcService = ExpressionCompilerService(
'localhost',
port,
assetHandler,
verbose: verboseCompiler,
sdkConfigurationProvider: sdkConfigurationProvider,
);
Expand Down
4 changes: 0 additions & 4 deletions dwds/test/fixtures/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ class TestServer {

cascade = cascade.add(dwds.handler).add(assetHandler);

if (ddcService != null) {
cascade = cascade.add(ddcService.handler);
}

serveHttpRequests(
server,
pipeline
Expand Down
3 changes: 3 additions & 0 deletions webdev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.7.11-dev
- Remove no longer used `ExpressionCompilerService.handler`.

## 2.7.10
- Pin DWDS version to avoid dependency conflicts with `package:vm_service`.

Expand Down
4 changes: 0 additions & 4 deletions webdev/lib/src/serve/webdev_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ class WebDevServer {
ddcService = ExpressionCompilerService(
options.configuration.hostname,
options.port,
assetHandler,
verbose: options.configuration.verbose,
);
}
Expand Down Expand Up @@ -161,9 +160,6 @@ class WebDevServer {
pipeline = pipeline.addMiddleware(dwds.middleware);
cascade = cascade.add(dwds.handler);
cascade = cascade.add(assetHandler);
if (ddcService != null) {
cascade = cascade.add(ddcService.handler);
}
} else {
cascade = cascade.add(assetHandler);
}
Expand Down
2 changes: 1 addition & 1 deletion webdev/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions webdev/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: webdev
# Every time this changes you need to run `dart run build_runner build`.
version: 2.7.10
version: 2.7.11-dev
# We should not depend on a dev SDK before publishing.
# publish_to: none
description: >-
Expand Down Expand Up @@ -34,7 +34,7 @@ dependencies:
shelf_static: ^1.1.0
stack_trace: ^1.10.0
sse: ^4.1.0
vm_service: ^8.3.0
vm_service: ^9.0.0
webkit_inspection_protocol: ^1.0.1
yaml: ^3.1.1

Expand All @@ -49,9 +49,9 @@ dev_dependencies:
webdriver: ^3.0.0

# Comment out before releasing webdev.
# dependency_overrides:
# dwds:
# path: ../dwds
dependency_overrides:
dwds:
path: ../dwds

executables:
webdev: