code-server icon indicating copy to clipboard operation
code-server copied to clipboard

Unix socket always be deleted after 3 hours when client disconnect

Open Mars160 opened this issue 1 year ago • 6 comments

Is there an existing issue for this?

  • [x] #7087

OS/Web Information

  • Web Browser: Safari
  • Local OS: iPadOS 17.1
  • Remote OS: Archlinux
  • Remote Architecture: amd64
  • code-server --version: 4.95.2

Steps to Reproduce

  1. run code-server with —socket and —socket-mode options behind nginx
  2. client to code-server, write something and disconnect
  3. wait for 3 hours
  4. the socket file is disappeared

logs below:


 [<unknown>][8ae2717b][ManagementConnection] The client has disconnected, will wait for reconnection 3h b>
11月 21 23:30:33 archlinux code-server[561098]: [23:30:33] [<unknown>][31fa6d6d][ExtensionHostConnection] <576182> Extension Host Process exited with code: 0, sign>
11月 21 23:30:36 archlinux code-server[561098]: [23:30:36] [<unknown>][4fe5bbb1][ExtensionHostConnection] <589581> Extension Host Process exited with code: 0, sign>
11月 21 23:30:36 archlinux code-server[561098]: [23:30:36] [<unknown>][4bad56e8][ExtensionHostConnection] <565453> Extension Host Process exited with code: 0, sign>
11月 21 23:30:42 archlinux code-server[561098]: [23:30:42] [<unknown>][550a7a3d][ExtensionHostConnection] <573629> Extension Host Process exited with code: 0, sign>
11月 21 23:31:09 archlinux code-server[561098]: [23:31:09] [<unknown>][8ae2717b][ManagementConnection] The reconnection grace time of 3h has expired, so the connec>

You will never reconnect to code-server because the socket file is delete.

Expected

Never delete the socket file unless code-server is stopped

Actual

It deleted!

Logs


Screenshot/Video

No response

Does this bug reproduce in native VS Code?

This cannot be tested in native VS Code

Does this bug reproduce in GitHub Codespaces?

I did not test GitHub Codespaces

Are you accessing code-server over a secure context?

  • [x] I am using a secure context.

Notes

my nginx config:


server {
    include common/listen-8096;
    server_name my.super.server;
    # set max upload size
    client_max_body_size 32G;
    fastcgi_buffers 64 4K;

  
    location / {
        proxy_pass http://unix:/dev/shm/code-server.sock;
        
        add_header Access-Control-Allow-Origin *;
         add_header Access-Control-Allow-Methods *;
         add_header Access-Control-Allow-Headers *;
 
         # proxy_ssl_verify off;
         proxy_set_header Host $host;
         proxy_set_header Accept-Encoding gzip;
         #proxy_set_header X-Forwarded-Host $host;
         proxy_set_header X-Forwarded-Host $host:$server_port;
 
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection $http_connection;
         proxy_http_version 1.1;

        access_log /var/log/nginx/code.log;
        error_log /var/log/nginx/code.error.log;
    }  
}

And systemctl edit code-server.service:


### Anything between here and the comment below will become the contents of the drop-in file

[Service]
ExecStart=
ExecStart=/usr/bin/code-server /my/super/path
User=superuser
Group=superuser

### Edits below this comment will be discarded


### /usr/lib/systemd/system/[email protected]
# [Unit]
# Description=code-server
# After=network.target
# 
# [Service]
# Type=exec
# ExecStart=/usr/bin/code-server
# Restart=always
# User=%i
# 
# [Install]
# WantedBy=default.target

And the config.yaml

auth: password
password: mysuperpassword
cert: false
socket: /dev/shm/code-server.sock
socket-mode: 666

Mars160 avatar Nov 21 '24 16:11 Mars160

Walkthrough

This pull request adds new test cases for the z.date() function that confirm a custom error message is produced when an invalid date is passed. Additionally, it updates the error handling logic in both the Deno and src type files by modifying the processCreateParams function. The new logic now treats "invalid_date" issues the same as "invalid_type" ones when deciding whether to return the default error message. No changes have been made to the exported or public entities.

Changes

File(s) Change Summary
deno/lib/__tests__/date.test.ts, src/__tests__/date.test.ts Added a test case titled "custom error message on invalid_date" to verify that z.date() throws an error with a custom message and the code "invalid_date".
deno/lib/types.ts, src/types.ts Updated the processCreateParams function to include a check for iss.code !== "invalid_date" alongside iss.code !== "invalid_type", altering error handling.

Sequence Diagram(s)

sequenceDiagram
    participant T as Test Case
    participant Z as z.date() Parser
    participant E as Error Handler
    T->>Z: Call z.date() with invalid date & custom error message
    Z-->>T: Throw error { code: "invalid_date", message: custom message }
    T->>T: Catch and assert error properties
sequenceDiagram
    participant C as Caller
    participant P as processCreateParams
    participant D as Default Error (ctx.defaultError)
    C->>P: Provide RawCreateParams with issue code
    P->>P: Check if iss.code is "invalid_type" or "invalid_date"
    alt Code is "invalid_type" or "invalid_date"
        P-->>C: Process using custom logic
    else
        P->>D: Retrieve default error message
        D-->>P: Return default error message
        P-->>C: Return processed result
    end

Poem

I'm a bunny with a skip in my hop,
Testing dates until the errors stop.
Custom messages now sing with cheer,
"Invalid_date" rings loud and clear.
Code gardens bloom in each new line,
Hoppy changes make our tests shine! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c7d8e503a324e7a9873d4c17af2a19738c63364 and cf219f0c13d3806e4667eb2c66a16fe4c5e8a4c0.

📒 Files selected for processing (4)
  • deno/lib/__tests__/date.test.ts (1 hunks)
  • deno/lib/types.ts (1 hunks)
  • src/__tests__/date.test.ts (1 hunks)
  • src/types.ts (1 hunks)
🔇 Additional comments (4)
src/__tests__/date.test.ts (1)

36-47: Good test implementation for custom error messages.

This test correctly verifies the new functionality allowing custom error messages for invalid dates. The test effectively:

  1. Creates an invalid date instance
  2. Configures a date schema with a custom message
  3. Verifies both the error code and custom message

The test case aligns perfectly with the PR objective of allowing users to specify custom error messages for the "invalid_date" issue code.

deno/lib/__tests__/date.test.ts (1)

37-48: Good test implementation for custom error messages in Deno.

This test ensures the custom error message functionality works consistently in the Deno environment, mirroring the Node.js test. It correctly validates that:

  1. The error code is "invalid_date"
  2. The custom message is properly applied

Maintaining parallel tests across both environments is a good practice for ensuring consistent behavior.

deno/lib/types.ts (1)

148-149: Enhance error handling to support custom error messages for invalid dates.

This change extends the condition to treat "invalid_date" issues the same way as "invalid_type" issues when determining whether to use a custom error message or the default one. This enhancement allows users to specify custom error messages for invalid date validations, making the API more consistent.

src/types.ts (1)

148-149: Approve: Adding support for custom error messages on invalid_date issue code.

This change extends the error handling to allow users to provide custom error messages for invalid dates, just like they can already do for invalid types. The implementation is clean and consistent with the library's pattern.

The modification ensures that when the issue code is "invalid_date" or "invalid_type", the provided custom message (if any) will be used instead of the default error message, which fulfills the PR objective.

✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Apr 01 '25 09:04 coderabbitai[bot]

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
Latest commit cf219f0c13d3806e4667eb2c66a16fe4c5e8a4c0
Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/67ebb6360efad500084d593a
Deploy Preview https://deploy-preview-4064--guileless-rolypoly-866f8a.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Apr 01 '25 09:04 netlify[bot]

Deployment failed with the following error:

Creating the Deployment Timed Out.

vercel[bot] avatar Apr 01 '25 10:04 vercel[bot]