toitlang / toitlang/pkg-http

Unexpected "Connection closed"

Open
#89 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Toit
Stars
3
Forks
2
Avg merge
53m
Merged PRs (30d)
1

Description

It seems like the client is not correctly reconnecting.

In a program that has no close on the Client I got the following stack trace:

This is with SDK alpha.74, and http version 2.1.0.

The project is https://github.com/floitsch/log-uploader

******************************************************************************
Decoding by `jag`, device has version <2.0.0-alpha.74>
******************************************************************************
EXCEPTION error. 
Connection closed
  0: tcp_error_                <sdk>/net/modules/tcp.toit:208:3
  1: TcpSocket_.ensure_state_  <sdk>/net/modules/tcp.toit:75:14
  2: TcpSocket.read            <sdk>/net/modules/tcp.toit:156:16
  3: BufferedReader.more_      <sdk>/reader.toit:82:22
  4: BufferedReader.ensure_    <sdk>/reader.toit:69:14
  5: BufferedReader.can_ensure <sdk>/reader.toit:109:5
  6: SymmetricSession_.read_   <sdk>/tls/session.toit:552:22
  7: SymmetricSession_.read.<block> <sdk>/tls/session.toit:541:14
  8: SymmetricSession_.read    <sdk>/tls/session.toit:539:3
  9: Session.read              <sdk>/tls/session.toit:258:54
 10: Socket.read               <sdk>/tls/socket.toit:94:21
 11: BufferedReader.more_      <sdk>/reader.toit:82:22
 12: BufferedReader.index_of   <sdk>/reader.toit:247:14
...
 20: catch                     <sdk>/core/exceptions.toit:122:1
 21: catch                     <sdk>/core/exceptions.toit:85:10
 22: Client.try_to_reuse_      <pkg:pkg-http>/client.toit:641:5
 23: Client.post_.<block>      <pkg:pkg-http>/client.toit:460:7
 24: SmallInteger_.repeat      <sdk>/core/numbers.toit:1194:3
 25: Client.post_              <pkg:pkg-http>/client.toit:458:19
 26: Client.post_json          <pkg:pkg-http>/client.toit:523:12
 27: Client.request_           <pkg:toit-supabase>/supabase.toit:270:33
 28: Client.request_           <pkg:toit-supabase>/supabase.toit:301:17
 29: PostgRest.insert          <pkg:toit-supabase>/supabase.toit:453:25
 30: main.<lambda>.<block>     main.toit:77:19
 31: Mutex.do.<block>          <sdk>/monitor.toit:28:27
 32: __Monitor__.locked_.<block> <sdk>/core/monitor_impl_.toit:123:12
 33: __Monitor__.locked_       <sdk>/core/monitor_impl_.toit:95:3
 34: Mutex.do                  <sdk>/monitor.toit:28:3
 35: main.<lambda>             main.toit:76:11
 36: main.<lambda>.<block>     main.toit:87:17
 37: LogForwarder.listen.<block> main.toit:38:7
 38: LogForwarder.listen       main.toit:58:18
 39: main.<lambda>             main.toit:86:17
******************************************************************************

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pkg-http/client.toit at Client.try_to_reuse_ and Client.post_, which appear in the stack trace, and review how a closed connection is handled during reuse. Reproduce the report using the linked log-uploader project and verify that a closed connection no longer surfaces unexpectedly when the client posts again.

Written by the indexing model from the issue text.

Assessment

Domain
api, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.