Posts deleted locally by a list sync while still in use (umbrella for several crashes)

オープン
#26,323 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
swift
領域
mobile

調査の方向性

Start in PostRepository.swift at paginate(...) and the purgeExisting logic; trace how first-page syncs interact with open editors, saves, and in-flight updates. Use the shared repro recipe with Network Link Conditioner, then check any proposed fix against all five linked crashes and the related stale-post bugs.

索引モデルが issue の本文から書いたものです。

説明

[Status] Needs Plan [Type] Bug Core Data Posts + Pages

Several crashes, and a few long-standing bugs, look like the same problem: a Post is deleted from Core Data while some part of the app is still using it, and that code then crashes or writes to it.

Mechanism (hypothesis, from the individual write-ups)

  • PostRepository.paginate(...) passes deleteOtherLocalPosts: offset == 0 (PostRepository.swift ~L506), which becomes purgeExisting (~L667). Every first-page sync of a post list deletes local posts that aren't in that page.
  • These syncs run often. Breadcrumbs show the main list re-syncing page 1 every few seconds, possibly triggered by NWPathMonitor reachability updates.
  • Places that still hold the deleted post then crash:
    • an in-flight save or status change (PostRepository, PostHelper.update)
    • an editor that's open or being opened (AztecPostViewController.init, GutenbergSettings.mustUseGutenberg)
    • a Posts search result row
    • While an editor is open, the post list stops observing changes (its fetch delegate is nil), so on-screen rows can point at deleted objects.

Crashes (Jetpack, last 30 days)

Issue Sentry Users (27.3) Crashes in
#26316 JETPACK-IOS-1JSW 78 (7.8× vs 27.2: a real regression) PostCategory.lookup after a quick status change
#26317 JETPACK-IOS-1BN2, 1CA4 51 + 32 Media.makeMedia(blog:), force-unwrapping blog.managedObjectContext!
#26318 JETPACK-IOS-1KJC 41 Blog.xmlrpcApi with post.blog == nil (crashes since #25869, 27.2)
#26319 JETPACK-IOS-1GFE (was 1HPP/1HQY) 46 classic editor init precondition
#26320 JETPACK-IOS-1KP9 (was 1JXN) 13 GutenbergSettings.mustUseGutenberg

27.3 has about 4.2× as many users as 27.2 in Sentry, so only 1JSW stands out per user. The others are steady and long-running.

Possibly related bugs: #24138 and #24245 (dashboard cards keep showing stale posts), and #24190 (trashing a stale draft can trash the published post).

Fix directions to evaluate

  1. Don't purge posts that are in use. Skip posts that have an open editor, a local revision, or an in-flight sync or save when purgeExisting runs.
  2. Check before using a post held across an await or a callback. Re-fetch by objectID with existingObject(with:), and bail out if isDeleted or managedObjectContext == nil, instead of force-unwrapping. That alone would turn most of these crashes into handled errors.
  3. Narrow the purge, for example only for list filters that are actually being refreshed, not on reachability-driven syncs.

A fix for (1) or (3) should be checked against all five crashes at once.

Shared repro recipe

Jetpack app, a WordPress.com site with more than 20 posts, and Network Link Conditioner set to add 2–3 s of latency.

  1. Open Posts. From a row's menu, change the status of a post that's near the bottom of the first page.
  2. While that request is in flight, pull to refresh, or toggle the network, so page 1 re-syncs.
  3. Variations: open a post in the editor, close it, and reopen it immediately. Open a post from Posts search while the list re-syncs.

Each linked issue has its own Sentry snapshot, breadcrumbs and event IDs.


Generated by Claude Code

主要言語
Swift
スター
3.9k
フォーク
1.2k
平均マージ
1日 23時間
マージ済み PR(30日)
136

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

wordpress-mobile/WordPress-iOS のほかの issue

wordpress-mobile/WordPress-iOS の issue をすべて見る

似ている issue

Swift の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。