Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hexo on exit event not triggered after all hexo process finished (onExit) #4822

Closed
5 tasks done
dimaslanjaka opened this issue Nov 22, 2021 · 4 comments
Closed
5 tasks done
Labels

Comments

@dimaslanjaka
Copy link
Contributor

dimaslanjaka commented Nov 22, 2021

Please check followings before submitting a new issue.

Environment & Settings

  • Node 14.18.1
  • NPM 8.1.3
  • hexo 5.4.0

Behavior

I just testing function to be executed before hexo exit, but why the function triggered before all events completed ?

todo:
manipulate the html code using JSDOM, then cache it so as not to process the same (duplicate) html string. then save it in file as cache before hexo exit (on exit) and restore that cache to object when hexo ready (on ready).
the manipulation process will be repeated if the page content changes (updated or edited), otherwise it will be returned according to the stored cache.
cache will be cleared when triggered by hexo clean.
in my case testing hexo event, i want to:

  • saving object cache to file before hexo exit hexo.on('exit')
  • restore object cache from file after hexo ready hexo.on('ready')

This is from my own plugin

// packages/hexo-seo/src/index.ts
hexo.on("exit", () => {
  console.log("Scheduling functions on process exit");
});

Others

image

@github-actions
Copy link

This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stevenjoezhang
Copy link
Member

These event callback functions are non-blocking. You will need to use some other methods to achieve this, such as registering filters.

@dimaslanjaka
Copy link
Contributor Author

These event callback functions are non-blocking. You will need to use some other methods to achieve this, such as registering filters.

such like registering function on process exit ?

@dimaslanjaka
Copy link
Contributor Author

done fixed by create my own schedule function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants