Skip to content
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

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

Merged
merged 3 commits into from
Apr 22, 2023
Merged

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

merged 3 commits into from
Apr 22, 2023

Conversation

Hanaasagi
Copy link
Contributor

@Hanaasagi Hanaasagi commented Apr 22, 2023

Fixes #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 mtshiba merged commit db9a7fd into erg-lang:main Apr 22, 2023
@mtshiba
Copy link
Member

mtshiba commented Apr 22, 2023

Thank you!

@Hanaasagi
Copy link
Contributor Author

Hanaasagi commented Apr 22, 2023

@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.

__client_socket.send('[Initialize]'.encode())
__out = __sys.stdout.getvalue()[:-1]
# assert not(__exc and __res)
if __exc or __res:
__out += '\n'
__res = __out + __exc + __res
__client_socket.send(__res.encode())

So there should be startswith , not match a string.

erg/src/dummy.rs

Lines 207 to 212 in b444fca

match s {
"[Exception] SystemExit" => Err(EvalErrors::from(EvalError::system_exit())),
"[Initialize]" => {
self.compiler.initialize_generator();
self.read()
}

2023-04-22_20-38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REPL: unexpected exception is thrown
2 participants