Guard against stale markers in async callbacks#281
Open
benthamite wants to merge 2 commits intokidd:masterfrom
Open
Guard against stale markers in async callbacks#281benthamite wants to merge 2 commits intokidd:masterfrom
benthamite wants to merge 2 commits intokidd:masterfrom
Conversation
When a buffer is killed while an async HTTP request is in flight, markers pointing into that buffer become stale: `marker-buffer' returns nil. Every `with-current-buffer (marker-buffer marker)' and `org-with-point-at marker' call in a deferred callback then signals an error because `set-buffer' receives nil. Add nil checks on `marker-buffer' before using markers in: - `org-gcal--with-point-at-no-widen' (macro) - `org-gcal--sync-update-entries' - `org-gcal--post-event' (HTTP 412 and success callbacks) - `org-gcal--delete-event' (HTTP 412 callback) - `org-gcal-delete-at-point' (:finally callback) Each guard signals a descriptive error that the existing `deferred:error' handlers can catch and log, rather than letting Emacs error out with a confusing "Wrong type argument: bufferp, nil".
9696a3f to
fcc8cdf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a buffer is killed while an async HTTP request is in flight, markers pointing into that buffer become stale (
marker-bufferreturns nil). Everywith-current-buffer (marker-buffer marker)andorg-with-point-at markercall in a deferred callback then signals an error becauseset-bufferreceives nil, producing a confusing "Wrong type argument: bufferp, nil".This occasionally happens during
org-gcal-syncin my experience.marker-buffernil check toorg-gcal--with-point-at-no-widenmacroorg-gcal--sync-update-entries,org-gcal--post-event(HTTP 412 and success callbacks),org-gcal--delete-event(HTTP 412 callback), andorg-gcal-delete-at-point(:finallycallback)deferred:errorhandlers catch and log gracefullyTest plan
org-gcal-syncand kill the calendar buffer while the sync is running — should log a message instead of erroring with "Wrong type argument: bufferp, nil"