superfly / fly

Deploy app servers close to your users. Package your app as a Docker image, and launch it in 17 cities with one simple CLI.
https://fly.io
985 stars 48 forks source link

Destination of error messages #198

Closed chilts closed 4 years ago

chilts commented 5 years ago

Currently in https://solitary-leaf-5893.edgeapp.net there is an error when making the collection. Here is the complete program which is the simplest I could do based on examples/object-store with a twist for me to see the value changing:

import db from '@fly/data'

fly.http.respondWith(async function (req) {
  console.log('req=' + req.url)

  const coll = db.collection("testing")

  const r = Math.floor(Math.random() * 1000)
  console.log('Putting id')
  await coll.put("id", { rand: r })
  console.log('Got id')

  console.log('Getting data')
  const data = await coll.get("id")
  console.log('Got data:', data)

  return new Response(JSON.stringify(data) + "\n")
})

At the moment when you curl the site the error comes back to the client:

$ curl https://solitary-leaf-5893.edgeapp.net
Error: Error: error getting or making collection

but the logs say (nothing):

2018-12-05T21:40:51Z ord1 [info] 99.104.68.96 GET https://solitary-leaf-5893.edgeapp.net/favicon.ico 200 694.20ms
2018-12-05T21:40:51Z ord1 [info] Getting data
2018-12-05T21:40:51Z ord1 [info] Got id

I think the reply to the client should just say 500 - Internal Server Error and the error should appear in the logs (or somewhere else perhaps), but just somewhere we can get at it.