erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.62k stars 53 forks source link

fix(repl): fix repl server crash when meet a exception #420

Closed Hanaasagi closed 1 year ago

Hanaasagi commented 1 year ago

Fixes https://github.com/erg-lang/erg/issues/419.

This is a brief description.

  1. fix the repl server crashed after exception
  2. exec user code in independent context.
  3. return exception info to client through the socket.

@mtshiba

mtshiba commented 1 year ago

Thank you!

Hanaasagi commented 1 year ago

@mtshiba Firstly, thank you for your correction. But there still exist some problems.

The following code uses sockets to send data to the client twice, although it involves two system calls. However, TCP is a stream-based protocol, so the client may receive the merged data while reading it sequentially.

https://github.com/erg-lang/erg/blob/b444fcac2c6025894e85fdfad691ab6b8f2a93af/src/scripts/repl_server.py#L47-L53

So there should be startswith , not match a string.

https://github.com/erg-lang/erg/blob/b444fcac2c6025894e85fdfad691ab6b8f2a93af/src/dummy.rs#L207-L212

2023-04-22_20-38