OfficeDev / OfficeDev/Office-Addin-Scripts

getProcessIdsForPort is getting false-positive results for mac, preventing start of dev server

Open
#950 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs triage
Dominant language
TypeScript
Stars
194
Forks
117
Avg merge
1d 32m
Merged PRs (30d)
2

Description

Prerequisites

Please answer the following questions before submitting an issue.
YOU MAY DELETE THE PREREQUISITES SECTION.

  • I am running the latest version of Node and the tools
  • [ X] I checked the documentation and found no answer
  • [ X] I checked to make sure that this issue has not already been filed

Expected behavior

When I run npx office-addin-debugging start manifest.xml I would expect the dev server to startup if it is not currently running.

Current behavior

The command used in lib/port.js - getProcessIdsForPort() for mac is lsof -n -i:${port} which in my case returns a slew of closed ports:

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Google 11139 xxxx 31u IPv6 0x5cd65a15b6a9ccf3 0t0 TCP [::1]:62738->[::1]:hbci (CLOSED)
Google 11139 xxxx 39u IPv6 0x996f8a475874a8bd 0t0 TCP [::1]:62729->[::1]:hbci (CLOSED)
Google 11139 xxxx 41u IPv6 0x34619b3341fc198f 0t0 TCP [::1]:62732->[::1]:hbci (CLOSED)
Google 11139 xxxx 42u IPv6 0x9ec275c68cf98fd0 0t0 TCP [::1]:62736->[::1]:hbci (CLOSED)
Google 11139 xxxx 45u IPv6 0x8f1977c32e340d7a 0t0 TCP [::1]:62737->[::1]:hbci (CLOSED)

By modifying the command to lsof -n -i:${port} -sTCP:LISTEN it correctly returns the correct PID when the dev server is properly running, or nothing at all if the service is not running.

Steps to Reproduce

I'm not sure how to reproduce the failure as I'm not sure what introduced the CLOSED hbci listeners.

Nothing in my chrome://serviceworker-internals/ seems to be attached to that port.

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Operating System: Mac Sonoma 14.6.1
  • Node version: 18+
  • Office version: Word Version 16.100.2 (25082415)
  • Tool version: 5.x but I confirmed the same CLI command is used in 6.x

Failure Logs

The found [ 11139 ] 3000 is a debug line I added to the source.

My start command is: "start": "office-addin-debugging start manifest.xml",

~/briefs % npm run start                                                            master

> office-addin-taskpane-js@0.0.1 start
> office-addin-debugging start manifest.xml

Debugging is being started...
App type: desktop
lsof -n -i:3000 -sTCP:LISTEN
found [] 3000
Starting the dev server... (webpack serve --mode development)
lsof -n -i:3000 -sTCP:LISTEN
found [] 3000
lsof -n -i:3000 -sTCP:LISTEN
found [] 3000
lsof -n -i:3000 -sTCP:LISTEN
found [ 11139 ] 3000
The dev server is running on port 3000. Process id: 11139
Sideloading the Office Add-in...
Launching word via /var/folders/pj/nlmngl1s32b52ryxsfyp2hw80000gn/T/Word add-in 95d9b863-d419-4b08-ba19-92820b857235.docx
Debugging started.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/port.js at getProcessIdsForPort() and trace how the office-addin-debugging start command checks the port. Compare the macOS lsof invocation with the reported -sTCP:LISTEN form. Done means closed connections no longer produce a process ID, while a listening dev server still does.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.