misskey-dev / misskey

🌎 A completely free and open interplanetary microblogging platform 🚀
https://misskey-hub.net/
GNU Affero General Public License v3.0
9.93k stars 1.34k forks source link

if a noteViewInterruptor plugin throws, all note displays break #14050

Closed dakkar closed 2 months ago

dakkar commented 3 months ago

💡 Summary

The install function packages/frontend/src/plugin.ts passes an err function to the Interpreter constructor, for the purpose of logging errors.

The Interpreter.handleError function, when an err is present, calls this.abort(). That makes all future calls to _eval (and therefore _run, and therefore exec) to return null. All future calls, because nothing ever resets the .stop attribute of the interpreter.

The MkNote*.vue components call all noteViewInterruptors one after the other, expecting them to return a Misskey.entities.Note | null, and when they return null, the note gets marked as deleted.

So, when a noteViewInterruptor's code throws an exception, all notes rendered after that will be considered deleted, and not shown.

🥰 Expected Behavior

🤬 Actual Behavior

📝 Steps to Reproduce

Install a plugin like:

/// @ 0.18.0
### {
  name: "test"
  version: "1.0.0-aiscript0.18.0"
  author: "@dakkar"
  description: "breaks"
  permissions: null
  config: null
}

Plugin:register_note_view_interruptor(@(note) {
  note.text.split(' ')
  return note
})

create a note with no text (e.g. just an image attached)

switch between "home" and "global" timeline

your timeline is now empty

💻 Frontend Environment

* Model and OS of the device(s): Linux
* Browser: Firefox 126
* Server URL: local test/dev instance
* Misskey: 2024.5.0

🛰 Backend Environment (for server admin)

* Installation Method or Hosting Service: local test/dev instance
* Misskey: 2024.5.0
* Node: 20.11.0
* PostgreSQL: 16.3
* Redis: 7.2.4
* OS and Architecture: linux amd64

Do you want to address this bug yourself?