start method

  1. @override
Future<ShellSession> start(
  1. ShellRequest request
)
override

Starts a session for request, returning a live ShellSession.

May throw if the command is invalid or the node is at capacity; the node runtime translates failures into a node.session.rejected message.

Implementation

@override
Future<ShellSession> start(ShellRequest request) async {
  final spec = request.pty;
  if (spec == null || !_winptyUsable) {
    return fallback.start(request);
  }

  if (allowCommand != null && !allowCommand!(request)) {
    throw ProcessException(
      request.command ?? defaultShell,
      request.args,
      'Command not permitted by node policy',
    );
  }

  try {
    return _spawn(request, spec);
  } on Object catch (e) {
    // Disable the winpty path for the rest of the process and fall back so the
    // session still works (with env-var geometry) instead of being rejected.
    _winptyUsable = false;
    onWarning?.call(
      'winpty PTY backend unavailable, using pipe fallback: $e',
    );
    return fallback.start(request);
  }
}