Skip to content

Fix #228: Replace hardcoded port 1108 with dynamic port allocation, s… - #239

Open
Ashutosh Mishra (Ashut0sh-mishra) wants to merge 1 commit into
microsoft:mainfrom
Ashut0sh-mishra:fix/issue-228-carbon-port
Open

Fix #228: Replace hardcoded port 1108 with dynamic port allocation, s…#239
Ashutosh Mishra (Ashut0sh-mishra) wants to merge 1 commit into
microsoft:mainfrom
Ashut0sh-mishra:fix/issue-228-carbon-port

Conversation

@Ashut0sh-mishra

Copy link
Copy Markdown

Summary

Fixes #228

Problem

The Carbon Sequestration notebook fails when run more
than once simultaneously because:

  • HTTP_SERVER_PORT was hardcoded to 1108 — second run
    crashes with "port already in use"
  • Global ngrok.kill() in finally block killed tunnels
    belonging to other running instances

Fix

  • comet_server.py: Replace hardcoded port 1108 with
    find_free_port() that binds to port 0 to get an
    OS-assigned available port
  • comet_server.py: Use self.port instance variable
    for per-server port isolation
  • comet_requester.py: Remove global ngrok.kill() from
    finally block — server.shutdown() already calls
    ngrok.disconnect() for current tunnel only
  • whatif_comet_local.py: Remove global ngrok.kill()
    from del and remove unused pyngrok import

Files Changed

  • notebooks/carbon/comet_server.py
  • notebooks/carbon/comet_requester.py
  • notebooks/carbon/whatif_comet_local.py

Validation

  • No hardcoded port 1108 references remain
  • Each server instance now gets its own OS-assigned port
  • ngrok cleanup is scoped to current tunnel only

Co-authors

Co-authored-by: nik464 nikhil18chaudhary@gmail.com

…cation, scope ngrok cleanup

- comet_server.py: Replace HTTP_SERVER_PORT=1108 with find_free_port()
  that binds to port 0 to get an OS-assigned available port
- comet_server.py: Use self.port instance variable for per-server port
- comet_requester.py: Remove global ngrok.kill() from finally block;
  server.shutdown() already calls ngrok.disconnect() for current tunnel
- whatif_comet_local.py: Remove global ngrok.kill() from __del__;
  remove unused pyngrok import

Co-authored-by: nik464 <nikhil18chaudhary@gmail.com>
@Ashut0sh-mishra

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for addressing the hard-coded webhook port. We cannot merge this as-is: the ngrok tunnel and agent lifecycle are not cleaned up, pyngrok still uses shared mutable configuration across runs, and choosing a free port before binding it retains a TOCTOU race. Please rebase onto current main, use per-run scoped configuration, bind the port atomically, and guarantee cleanup on success and failure. Note that #199 is a separate COMET API v2.5 compatibility issue.

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.

Intermittent Failure When Running Carbon Sequestration Notebook

2 participants