Skip to content

Ensure app_uri.txt is cleaned up when Rails server shuts down #87

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

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

andyw8
Copy link
Contributor

@andyw8 andyw8 commented Jun 22, 2023

The app_uri.txt file should only exist when the server is running. The extension uses its presence to report if the server is running or not. If the server is not running, some of the extension features will not be available.

🎩 completed.

@andyw8 andyw8 added the bugfix This PR fixes an existing bug label Jun 22, 2023
@andyw8 andyw8 added this to the 2023-Q2 milestone Jun 22, 2023
@andyw8 andyw8 requested a review from a team as a code owner June 22, 2023 16:16
@andyw8 andyw8 requested review from egiurleo and KaanOzkan June 22, 2023 16:16
Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

👍

@andyw8 andyw8 merged commit 62cbae4 into main Jun 22, 2023
@andyw8 andyw8 deleted the andyw8/ensure-app-uri-file-cleaned-up branch June 22, 2023 16:43
@vinistock
Copy link
Member

I'm not sure I understand. We check if the server is running by making a request to it.

But we need to ensure that app_uri.txt exists because otherwise we don't know the URL we need to make requests against.

The extension currently complains if app_uri.txt doesn't exist because we wouldn't know which URL to make requests against.

The idea of that error was for it to show up once and then after restarting the server the file would exist and you'd never need to do it again.

@st0012
Copy link
Member

st0012 commented Jun 22, 2023

What do we gain from keeping it there even when the server is not up anymore?

If you had previously run ruby-lsp-rails with your server and then shut it down, the file would be left there. So the file check would not be raised correctly even though the server is not up anymore.

@vinistock
Copy link
Member

Well, in my head the question is inverted. Why add extra code to clean this up if we always need to know the app's URL and port?

Adding extra code can always bring up unexpected maintenance. For example, what happens with this at_exit hook if someone decides to delete the file while the server is running? Will it raise? And in that case, what's the state of the server?

Checking if the server is running based on the file is more brittle than actually making a request and verifying that it is responding.

@st0012
Copy link
Member

st0012 commented Jun 23, 2023

As long as our implementation still relies on the file's presence as a state, either for error like now or just a warning like in #88, we should make sure the state doesn't leak to another run.

If we don't do things based on File.exist?(app_uri_path) anymore, I'm fine with leaving it uncleaned.

@shopify-shipit shopify-shipit bot temporarily deployed to production June 30, 2023 19:47 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants