Skip to content

🐛 RangeError (code): Invalid value: Not in inclusive range 3000..4999: 1000 after updating to 3.0.0 from 2.4.0 #1683

@tempo-riz

Description

@tempo-riz

Hello after upgrading the package from 2.4.0 to 3.0.0 calling close seems to throw (was tested and full working before upgrading) am I missing something ?

For a bit of context the code sends audio data to a server, which returns the transcription
First I start the connection :

  Future<void> start() async {
    _wsChannel = WebSocketChannel.connect(
      buildUrl(_baseLiveUrl, null, queryParams),
      protocols: ['token', apiKey],
    );
    await _wsChannel.ready;

    _wsChannel.stream.listen((event) {
      if (_outputTranscriptStream.isClosed) {
        close();
      } else {
        _outputTranscriptStream.add(...)
      }
    }, onDone: () {
      close();
    }, onError: (error) {
      _outputTranscriptStream.addError(...)
    });

    inputAudioStream.listen((data) {
      if (_wsChannel.closeCode != null) {
        close();
      } else {
        _wsChannel.sink.add(data);
      }
    }, onDone: () {
      close();
    });
  }

The error occurs in the close method :

  Future<void> close() async {
    await _wsChannel.sink.close(status.normalClosure); <------ this throws the following error
    await _outputTranscriptStream.close();
  }

The error :

  RangeError (code): Invalid value: Not in inclusive range 3000..4999: 1000
  dart:core                                                          RangeError.checkValueInInterval
  package:web_socket/src/utils.dart 10:16                            checkCloseCode
  package:web_socket/src/io_web_socket.dart 108:5                    IOWebSocket.close
  package:web_socket_channel/adapter_web_socket_channel.dart 112:27  new AdapterWebSocketChannel.<fn>.<fn>
  package:stream_channel                                             _GuaranteeSink.close
  package:async/src/delegate/stream_sink.dart 47:27                  DelegatingStreamSink.close
  package:web_socket_channel/adapter_web_socket_channel.dart 147:18  _WebSocketSink.close
  package:deepgram_speech_to_text/src/deepgram.dart 68:27            DeepgramLiveTranscriber.close
  package:deepgram_speech_to_text/src/deepgram.dart 62:7             DeepgramLiveTranscriber.start.<fn>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions