{"action":"created","issue":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/5255","repository_url":"https://api.github.com/repos/gatsbyjs/gatsby","labels_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/5255/labels{/name}","comments_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/5255/comments","events_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/5255/events","html_url":"https://github.com/gatsbyjs/gatsby/issues/5255","id":320015902,"node_id":"MDU6SXNzdWUzMjAwMTU5MDI=","number":5255,"title":"Programatically created Pages do not trigger onCreatePage","user":{"login":"mbergeronupgrade","id":29203843,"node_id":"MDQ6VXNlcjI5MjAzODQz","avatar_url":"https://avatars1.githubusercontent.com/u/29203843?v=4","gravatar_id":"","url":"https://api.github.com/users/mbergeronupgrade","html_url":"https://github.com/mbergeronupgrade","followers_url":"https://api.github.com/users/mbergeronupgrade/followers","following_url":"https://api.github.com/users/mbergeronupgrade/following{/other_user}","gists_url":"https://api.github.com/users/mbergeronupgrade/gists{/gist_id}","starred_url":"https://api.github.com/users/mbergeronupgrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbergeronupgrade/subscriptions","organizations_url":"https://api.github.com/users/mbergeronupgrade/orgs","repos_url":"https://api.github.com/users/mbergeronupgrade/repos","events_url":"https://api.github.com/users/mbergeronupgrade/events{/privacy}","received_events_url":"https://api.github.com/users/mbergeronupgrade/received_events","type":"User","site_admin":false},"labels":[{"id":214544672,"node_id":"MDU6TGFiZWwyMTQ1NDQ2NzI=","url":"https://api.github.com/repos/gatsbyjs/gatsby/labels/%F0%9F%8F%B7%20type:%20bug","name":"🏷 type: bug","color":"d93f0b","default":false},{"id":214544675,"node_id":"MDU6TGFiZWwyMTQ1NDQ2NzU=","url":"https://api.github.com/repos/gatsbyjs/gatsby/labels/%F0%9F%93%8D%20status:%20help%20wanted","name":"📍 status: help wanted","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-05-03T17:42:03Z","updated_at":"2018-08-01T22:05:26Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n  If you're reading this... it means that you want to contribute to the project! Awesome and thanks!\r\n\r\n  To make it easier for us to help you — please follow the suggested format below (as it makes sense).\r\n\r\n  Useful Links:\r\n  - Documentation: https://www.gatsbyjs.org/docs/\r\n  - How to Contribute: https://www.gatsbyjs.org/docs/how-to-contribute/\r\n  - How to File an Issue: https://www.gatsbyjs.org/docs/how-to-file-an-issue/\r\n  - Become a Sponsor: https://opencollective.com/gatsby#sponsor\r\n\r\n  Before opening a new issue, please search existing issues (https://github.com/gatsbyjs/gatsby/issues)\r\n  to double-check your issue isn't already known.\r\n-->\r\n\r\n## Description\r\n\r\nWhen creating pages programatically in `gatsby-node.js` they do not trigger the `onCreatePage` function. See log below\r\n\r\n### Steps to reproduce\r\n\r\nCall the createPage function within the `exports.createPages` function in `gatsby-node.js`\r\n\r\n### Expected result\r\n\r\nThe `exports.onCreatePage` handler is called.\r\n\r\n### Actual result\r\n\r\nI put a console log in before the `createPage` function and another console log in the `exports.onCreatePage`. Notice how the only calls to onCreatePage logged are for pages within the `pages` folder and not the programatically created ones.\r\n\r\n```\r\nsuccess createLayouts — 0.015 s\r\n⠁ CREATING PAGE:  blog-post\r\nCREATING PAGE:  blog-post\r\nCREATING PAGE:  blog-post\r\nCREATING PAGE:  press-release\r\nCREATING PAGE:  blog-post\r\nCREATING PAGE:  blog-post\r\nCREATING PAGE:  blog-post\r\nsuccess createPages — 0.053 s\r\n⠁ ON PAGE CREATED /dev-404-page/\r\nON PAGE CREATED /404/\r\nON PAGE CREATED /blog/\r\nON PAGE CREATED /\r\nON PAGE CREATED /press/\r\nON PAGE CREATED /404.html\r\n```\r\n\r\n### Environment\r\n\r\n* Gatsby version (`1.9.253`):\r\n* Node.js version: 8.11.1\r\n* Operating System: OSX\r\n"},"comment":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/comments/409740325","html_url":"https://github.com/gatsbyjs/gatsby/issues/5255#issuecomment-409740325","issue_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/5255","id":409740325,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTc0MDMyNQ==","user":{"login":"pieh","id":419821,"node_id":"MDQ6VXNlcjQxOTgyMQ==","avatar_url":"https://avatars1.githubusercontent.com/u/419821?v=4","gravatar_id":"","url":"https://api.github.com/users/pieh","html_url":"https://github.com/pieh","followers_url":"https://api.github.com/users/pieh/followers","following_url":"https://api.github.com/users/pieh/following{/other_user}","gists_url":"https://api.github.com/users/pieh/gists{/gist_id}","starred_url":"https://api.github.com/users/pieh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pieh/subscriptions","organizations_url":"https://api.github.com/users/pieh/orgs","repos_url":"https://api.github.com/users/pieh/repos","events_url":"https://api.github.com/users/pieh/events{/privacy}","received_events_url":"https://api.github.com/users/pieh/received_events","type":"User","site_admin":false},"created_at":"2018-08-01T22:05:26Z","updated_at":"2018-08-01T22:05:26Z","author_association":"CONTRIBUTOR","body":"Thanks @Chuloo for reproduction!\r\n\r\nSo here's my findings why this is happening:\r\nhttps://github.com/gatsbyjs/gatsby/blob/d213693ef90f07c8a1b4e43db427327499b429ba/packages/gatsby/src/utils/api-runner-node.js#L167-L178\r\n\r\nBecause only plugin name is being tracked and not what API hook `createPage` was called in - it will skip calling `onCreatePage` in the same `gatsby-node.js` file.\r\n\r\nPotential solutions:\r\n - track both plugin name and originating api hook, or\r\n - don't emit `CREATE_PAGE` action if page didn't change (which should prevent infinite loop) and remove code I linked above"}}
{"actor":{"display_login":"pieh"}}