@xt61 If you are not talking about the code showed by me, then you better should open a new post with your own issued situation.
I asume that your code …
$w("#commentswrite").onAfterSave(()=>{
…has nothing to do with this post (or you do not show enough of your code).