Skip to content

Conversation

@nerdrew
Copy link
Collaborator

@nerdrew nerdrew commented Apr 24, 2025

  • update rubocop, and fix all rubocop failures
  • Refactor specs

@nerdrew nerdrew force-pushed the lazarus/isolated-eval branch 4 times, most recently from 0cc67f5 to 7b90edb Compare April 25, 2025 15:42
Copy link
Collaborator

@doctown doctown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this.

socket&.close
end
rescue Exception => e # rubocop:disable Lint/RescueException
logger&.error { "debug-socket-error=#{e.inspect} DebugSocket is broken now path=#{@path} backtrace=#{e.backtrace.inspect}" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the message inform the user to restart the connection or try another socket?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no other socket. This message means the debug socket server is broken and the process would need to be restarted. This is a fatal (for the debug socket at least) error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we have ever seen this in practice. BUT I noticed it when testing. When I typo-ed a line, there were a LOT of logs spewing the error because we had a rescue Exception inside a loop. I've now changed it to have a rescue Exception on the eval above (we don't want user input to disrupt anything). But we shouldn't be rescuing SyntaxErrors in this file itself.

Now, we only allow 20 errors that aren't cause by the eval itself, e.g. a socket error can happen if the client writes to the socket and then closes really quickly before it has time to respond. I think that is ok. I don't know how to distinguish "there's something wrong with the socket and we shouldn't infinite loop spewing errors" vs "the client did something wrong and we should rescue the error and keep going". I think it's better to fail VERY conservatively for a debug tool. I never want DebugSocket to interrupt or negatively impact a running process (of course you can do that yourself by sending exit as your command, but don't do that).

rescue Exception => e # rubocop:disable Lint/RescueException
logger&.error "debug-socket-error=callback unsuccessful: #{e.inspect} for #{input.inspect} path=#{@path} backtrace=#{e.backtrace.inspect}"
end

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding a commend explaining why this is being introduced or what we're trying to avoid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I think I'm going to move it into it's own empty module in fact.

@nerdrew nerdrew force-pushed the lazarus/isolated-eval branch from 7b90edb to 80d36f6 Compare April 25, 2025 23:49
module Commands
# When running `eval`, we don't want the input to overwrite local variables etc. `eval` runs in the current scope,
# so we have an empty scope here that runs in a module that only has other shortcut commands the client might want
# to run.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doctown comment as requested.

@doctown
Copy link
Collaborator

doctown commented Apr 26, 2025

Not sure if its worth updating the CHANGELOG with this change. Most is encapsulated in the change I mentioned.

@nerdrew nerdrew force-pushed the lazarus/isolated-eval branch from 80d36f6 to 8a72747 Compare April 28, 2025 16:34
@nerdrew
Copy link
Collaborator Author

nerdrew commented Apr 28, 2025

Not sure if its worth updating the CHANGELOG with this change. Most is encapsulated in the change I mentioned.

Ah, I should add a changelog entry. This is a big change (in terms of lines of code changed).

- update rubocop, and fix all rubocop failures
- Refactor specs
- add github actions CI
- remove travis CI
@nerdrew nerdrew force-pushed the lazarus/isolated-eval branch from 8a72747 to 244d54e Compare April 29, 2025 16:41
@nerdrew nerdrew merged commit b3c056d into master Apr 29, 2025
4 checks passed
@nerdrew nerdrew deleted the lazarus/isolated-eval branch April 29, 2025 16:43
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.

4 participants