serverless-http 2.0.0 with express
Hi !
We have a serverless application which use serverless-http 2.0.0 with express 4.16.4 and during a deploy, express seems not to recognise route.. We have make a rollback to 1.8.0 of serverless-http to make it works.. Do you have an idea why this could happen ?
Thx
Crap sorry to hear that. Are you doing any other stuff in your handler or does it module.exports = serverless(app)?
Hi ! Thx for the quick answer ! Yes we are doing that at the end of our file : module.exports.handler = serverless(app)
Should I remove that line or do something else ?
nope that's still right, just making sure there was nothing else being done before/after -- I will have a look and see if I can reproduce
This is the last line of my file.. And no changes have been made between 1.8.0 and 2.0.0 and it crashed..
Thx
Can you try 2.0.1?
I will try on the next day.. I will keep you update!
Hi, I also have an issue with 2.0.1 & express 4.16.4 I upgraded from 1.8
Rolling back to 1.10.1 works for me
Are you using a custom domain?
Not for me... It's default domain by aws but in the future it could be possible
I really want to get this fixed. Anything you can share would be helpful - error messages, logs, sample code..
I've updated the integration tests and they still pass, they could certainly use more test scenarios but I'm confused.
I've also deployed real prod software (using Koa) and it works. What express middleware are you using?
Hi !
Here a sample of my code which i deploy simply on Lambda.
// Built-in
const { log } = console
// 3rd party lib
const serverless = require('serverless-http')
const bodyParser = require('body-parser')
const express = require('express')
const cors = require('cors')
const AWS = require('aws-sdk')
const { v4 } = require('uuid');
const app = express()
const { REPORT_TABLE } = process.env
const dynamoDb = new AWS.DynamoDB.DocumentClient()
app.use(cors())
app.use(bodyParser.json({strict: false}))
app.get('/', (req, res) => {
res.send('Welcome')
})
// FIXME: For tree creation, validate existence of projectId and enterpriseId.
// FIXME: For enterpriseId we should use credential to infer correct enterpriseId.
// ------------------------------------------------------------------------------
// report (FIXME)
// ------------------------------------------------------------------------------
// FIXME: API call to Generate all monthly report Item
app.get('/report', (req, res) => { // Return back all monthly reports
const TableName = REPORT_TABLE
dynamoDb.scan(
{ TableName },
(error, data) => {
if (error) {
log(error)
res.status(400).json({error, message: `Can not list Report.`})
} else {
res.json(data.Items)
}
}
)
})
module.exports.handler = serverless(app)
I didn't test on 2.0.1 but this code without change is not working on 2.0.0
Hope it helps you to find you..
I have no log to show you because nothing appear except a 404 error when I call an endpoint when I'm on AWS Lambda
Yeah please try 2.0.1 it definitely fixed a routing bug.
@daniplaninc could you share more info about your errors?
@dougmoscrop thx you for the update now it's working ! For me this issue can be close now !
I am using Nuxt.js and there weren't any errors, just a timeout. I will take some time to try again this week to reproduce the issue and to see if I can get any more information out of it
Thanks - is Nuxt.js something we should add tests for? Or is it just using another framework under the hood?
I created a reproduction example for you. In this example I use serverless-offline but I tested with actual deployment to AWS and the result is identical. I don't know how to provide more debugging output, but if you need it and tell me how, I can do that.
To run the example you can either follow the steps outlined in STEPS.md STEPS.zip to recreate the whole thing or just download the zip file STEPS.zip (where i already did the steps) and run:
- npm i
- continue from step 7 in STEPS.md
As to whether you should have tests for Nuxt.js I really don't know. Probably not, since the link between Nuxt.js and serverless is express (in my case).
Nuxt.js is a SSR framework for Vue.js. I could not find any official examples for Nuxt.js + serverless, so I used some slightly outdated sources (https://github.com/jeehyukwon/nuxt-serverless, https://github.com/adnanrahic/serverless-side-rendering-vue-nuxt) to get started and modified/fixed the code accordingly.
Thanks have reproduced and now get to go down the "how did this ever work" rabbit hole
I created a reproduction example for you. In this example I use serverless-offline but I tested with actual deployment to AWS and the result is identical. I don't know how to provide more debugging output, but if you need it and tell me how, I can do that.
To run the example you can either follow the steps outlined in STEPS.md STEPS.zip to recreate the whole thing or just download the zip file STEPS.zip (where i already did the steps) and run:
- npm i
- continue from step 7 in STEPS.md
As to whether you should have tests for Nuxt.js I really don't know. Probably not, since the link between Nuxt.js and serverless is express (in my case).
Nuxt.js is a SSR framework for Vue.js. I could not find any official examples for Nuxt.js + serverless, so I used some slightly outdated sources (https://github.com/jeehyukwon/nuxt-serverless, https://github.com/adnanrahic/serverless-side-rendering-vue-nuxt) to get started and modified/fixed the code accordingly.
@daniplaninc I experienced the same issue with the same stack (Nuxtjs + Serverless + Lambda). I can't get it works after deploying to Lambda for almost two weeks. It is really frustrating...
@smallcar88 my workaround for now is downgrading to 1.10.1
Based on my debugging I can't tell if I've reproduced the issue or just set nuxt up wrong. Can you just push a public repo that I can clone and npm install / npm start and then use my debugging stuff that way?