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

Crash in feed controller #676

Closed
aciccarello opened this issue Dec 23, 2023 · 2 comments · Fixed by #683
Closed

Crash in feed controller #676

aciccarello opened this issue Dec 23, 2023 · 2 comments · Fixed by #683
Assignees
Labels
bug Something isn't working

Comments

@aciccarello
Copy link

Description of the bug

My instance keeps crashing. Looking at the last thing in the logs it seems like there needs to be an undefined check at the following line.

2023-12-11T08:04:05.271Z indiekit:request url GET /auth
2023-12-11T08:04:05.272Z indiekit:request headers {
  host: 'indiekit.ciccarello.me',
  'user-agent': 'LightspeedSystemsCrawler Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)',
  accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'accept-encoding': 'gzip',
  'cdn-loop': 'cloudflare',
  'cf-connecting-ip': '52.36.251.200',
  'cf-ipcountry': 'US',
  'cf-ray': '833c36fbd9063078-SEA',
  'cf-visitor': '{"scheme":"https"}',
  'cf-warp-tag-id': 'effd0e18-0f7c-4ad6-8843-f97e1e26a62d',
  connection: 'keep-alive',
  referer: 'https://ciccarello.me',
  'x-forwarded-for': '52.36.251.200',
  'x-forwarded-proto': 'https'
}
2023-12-11T08:04:05.273Z indiekit:request body {}
2023-12-11T08:04:05.973Z indiekit:request url GET /feed.jf2
2023-12-11T08:04:05.974Z indiekit:request headers {
  host: 'indiekit.ciccarello.me',
  'user-agent': 'LightspeedSystemsCrawler Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)',
  accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'accept-encoding': 'gzip',
  'cdn-loop': 'cloudflare',
  'cf-connecting-ip': '52.36.251.200',
  'cf-ipcountry': 'US',
  'cf-ray': '833c37004cfec371-SEA',
  'cf-visitor': '{"scheme":"https"}',
  'cf-warp-tag-id': 'effd0e18-0f7c-4ad6-8843-f97e1e26a62d',
  connection: 'keep-alive',
  referer: 'https://ciccarello.me',
  'x-forwarded-for': '52.36.251.200',
  'x-forwarded-proto': 'https'
}
2023-12-11T08:04:05.974Z indiekit:request body {}
file:///ciccarello-indiekit/node_modules/@indiekit/indiekit/lib/controllers/feed.js:5
    .find({
     ^

TypeError: Cannot read properties of undefined (reading 'find')
    at jf2 (file:///ciccarello-indiekit/node_modules/@indiekit/indiekit/lib/controllers/feed.js:5:6)
    at Layer.handle [as handle_request] (/ciccarello-indiekit/node_modules/express/lib/router/layer.js:95:5)
    at next (/ciccarello-indiekit/node_modules/express/lib/router/route.js:144:13)
    at Route.dispatch (/ciccarello-indiekit/node_modules/express/lib/router/route.js:114:3)
    at Layer.handle [as handle_request] (/ciccarello-indiekit/node_modules/express/lib/router/layer.js:95:5)
    at /ciccarello-indiekit/node_modules/express/lib/router/index.js:284:15
    at Function.process_params (/ciccarello-indiekit/node_modules/express/lib/router/index.js:346:12)
    at next (/ciccarello-indiekit/node_modules/express/lib/router/index.js:280:10)
    at file:///ciccarello-indiekit/node_modules/@indiekit/indiekit/lib/routes.js:34:5
    at Layer.handle [as handle_request] (/ciccarello-indiekit/node_modules/express/lib/router/layer.js:95:5)

Node.js v20.9.0

Steps to reproduce

  1. Run indiekit without a database
  2. Hit the jf2 feed endpoint??

Expected behaviour

Some kind of error response in http, not an application crash.

Environment

https://github.com/aciccarello/ciccarello-indiekit/blob/1f7ef327c42ee45a0ca8aa9a5f7a7a8b852d47ba/package.json#L29-L32

https://github.com/aciccarello/ciccarello-indiekit/blob/1f7ef327c42ee45a0ca8aa9a5f7a7a8b852d47ba/.nvmrc#L1

Self hosted on a local machine

Additional context

No response

@aciccarello aciccarello added the bug Something isn't working label Dec 23, 2023
@paulrobertlloyd
Copy link
Collaborator

How odd. application.posts should always exist as it’s initiated on start-up, and find() should return an empty array if no items are found. Will investigate.

@paulrobertlloyd
Copy link
Collaborator

The posts query needed a database check before calling application.posts. Fix will ship with the next beta. I’m thinking it might be desirable to fallback to data stored in memory if a database isn’t available, but probably best to leave that until after 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants