Skip to content

Chat disappearing/not persisted when sent in cli #349

@ambiencepatrick

Description

@ambiencepatrick

Describe the bug
When I start the chat cli via instagram-cli chat and write send the dm, sometimes the dm text is not persisted and will disappear. The receiver will also get a notification with that text in the notification body, but will not see the actual text when they go into the chat.

Some texts are persisted, but some are not. It is very random.

System Information:

  • OS: Mac OS Tahoe 26.4.1
  • Terminal: iTerm 2 + oh-my-zsh
  • Client: Typescript
  • Instagram CLI Version:
instagram-cli: v1.5.0
Using:
  instagram-private-api: v1.46.1 (patched)
  Instagram app version: 416.0.0.47.66

Logs (optional)

2026-05-18T07:59:17.621Z DEBUG [InstagramClient]: Received MQTT "message": {"event":"patch","message_type":1,"seq_id":441569,"tq_seq_id":0,"mi_trace_id":7564513394821363000,"mutation_token":"7462049158499138509","client_context":"7462049158499138509","realtime":true,"delta_type":"deltaMarkRead","message":{"path":"/direct_v2/threads/340282366841710301244260070981285546847/participants/2087675183/has_seen","op":"replace","thread_id":"340282366841710301244260070981285546847","item_id":"32818437936077887570249017848758272","client_context":"7462049158499138509","timestamp":1779091085394000,"created_at":1779091085393817,"shh_seen_state":{},"disappearing_messages_seen_state":{}}}
2026-05-18T07:59:19.131Z DEBUG:   �[38;5;185;1mig:state �[0mCould not find csrftoken �[38;5;185m+2s�[0m

2026-05-18T07:59:19.132Z DEBUG:   �[38;5;45;1mig:request �[0mRequesting POST /api/v1/direct_v2/threads/broadcast/text/ �[38;5;45m+2s�[0m

2026-05-18T07:59:19.131Z DEBUG:   �[38;5;185;1mig:state �[0mcsrftoken lookup failed, returning "missing". �[38;5;185m+0ms�[0m

2026-05-18T07:59:19.875Z DEBUG:   �[38;5;128;1mig:mqtt:realtime:message �[0mReceived raw on /ig_message_sync: (1112 bytes) "[{"event":"patch","data":[{"op":"add","path":"/direct_v2/threads/340282366841710301244260070981285546847/items/3281843[128...]" �[38;5;128m+2s�[0m

2026-05-18T07:59:19.876Z DEBUG [InstagramClient]: Received MQTT "message": {"event":"patch","message_type":1,"seq_id":441570,"tq_seq_id":null,"mi_trace_id":8193627712115533000,"mutation_token":"ffb3be32-ce21-51b7-ad5d-076b6c50bb40","client_context":"ffb3be32-ce21-51b7-ad5d-076b6c50bb40","realtime":true,"delta_type":"deltaNewMessage","message":{"path":"/direct_v2/threads/340282366841710301244260070981285546847/items/32818439312042350526483671285760000","op":"add","thread_id":"340282366841710301244260070981285546847","item_id":"32818439312042350526483671285760000","message_id":"mid.$cAAAOTS00jXaka14DsQAAAAAAAAAA","user_id"[REDACTED],"timestamp":1779091159985000,"item_type":"text","client_context":"0","show_forward_attribution":false,"forward_score":null,"is_shh_mode":false,"otid":"0","is_ae_dual_send":false,"is_ephemeral_exception":false,"is_disappearing":false,"is_superlative":false,"paid_partnership_info":{"is_paid_partnership":false},"is_replyable_in_bc":false,"skip_bump_thread":false,"can_have_attachment":true,"is_cutout_sticker_creation_allowed":false,"latest_snooze_state":0,"one_click_upsell":null,"genai_params":{},"text":"Hehe","snippet":{}}}
2026-05-18T07:59:20.045Z DEBUG:   �[38;5;128;1mig:mqtt:realtime:message �[0mReceived on /ig_send_message_response: {"action":"item_ack","status_code":"400","message":"None","payload":{"client_context":null,"message":"None"},"status":"fail"} �[38;5;128m+170ms�[0m

2026-05-18T07:59:23.706Z DEBUG:   �[38;5;185;1mig:state �[0mcsrftoken lookup failed, returning "missing". �[38;5;185m+1ms�[0m

2026-05-18T07:59:23.705Z DEBUG:   �[38;5;185;1mig:state �[0mCould not find csrftoken �[38;5;185m+5s�[0m

2026-05-18T07:59:23.706Z DEBUG:   �[38;5;45;1mig:request �[0mRequesting POST /api/v1/direct_v2/threads/broadcast/text/ �[38;5;45m+5s�[0m

Additional Info

  • This was some info I got from asking Codex:
I found the failure mode.

  instagram-cli chat is sending text through Instagram’s private REST endpoint:

  /opt/homebrew/lib/node_modules/@i7m/instagram-cli/node_modules/instagram-private-api/dist/entities/direct-
  thread.entity.js:20 → broadcastText(...)
  /opt/homebrew/lib/node_modules/@i7m/instagram-cli/node_modules/instagram-private-api/dist/repositories/direct-
  thread.repository.js:171 → POST /api/v1/direct_v2/threads/broadcast/text/

  In the logs, Instagram first emits a transient deltaNewMessage, then immediately rejects the send over MQTT:

  /Users/apple/.instagram-cli/logs/session-2026-05-18_07.log:260: text broadcast request
  /Users/apple/.instagram-cli/logs/session-2026-05-18_07.log:266: temporary deltaNewMessage appears
  /Users/apple/.instagram-cli/logs/session-2026-05-18_07.log:267: /ig_send_message_response returns status:"fail",
  status_code:"400"

  That explains the exact symptom: Instagram’s realtime path briefly creates enough state to notify the receiver,
  but final persistence is rejected, so the message is not in the chat when they open it.

  The CLI also does not handle that failure ack. It listens to normal realtime message events, so it treats the
  transient deltaNewMessage as real and never reports the later 400 failure.

  A few concrete notes:

  - I counted 31 broadcast/text attempts in the logs; the text-send acks I inspected failed with 400.
  - The only status:"ok" ack I found was for a reaction, not text.
  - @i7m/instagram-cli@1.5.0 is already the latest npm release, so npm update -g @i7m/instagram-cli will not fix
    this.
  - The exact server-side rejection reason is not exposed; Instagram returns "message":"None". The strongest
    evidence points to the CLI using an outdated/unreliable private direct-message send path.

  I didn’t change any files. The practical short-term answer is: don’t rely on instagram-cli chat for text sends. A
  real fix would be a CLI patch to either send text through the existing MQTT realtime.direct.sendText(...) path and
  wait for /ig_send_message_response, or at minimum surface failed acks so the UI doesn’t imply the message was
  sent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions