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

Issue in v6.7.0 causing invocations to fail on subsequent attempts #1100

Closed
dustinsgoodman opened this issue Sep 15, 2020 · 7 comments
Closed

Comments

@dustinsgoodman
Copy link

Bug Report

Discovered a bug in v6.7.0 that wasn't present in v6.6.0. When invoking functions, I'm seeing:

Current Behavior
When invoking functions against my service, I'm seeing the aforementioned rejection errors from the framework. When running v6.6.0 of the library, everything works as intended but v6.7.0 has this bug.

Sample Code
Here's a branch with full reproduction. Was able to get v6.6.0 working on it and once I upgraded to v6.7.0 it failed: dustinsgoodman/serverless-microservices-graphql-template#13

Expected behavior/code
I should be able to run my lambda function twice in succession without a failure.

Environment

  • serverless version: v2.0.0
  • serverless-offline version: v6.7.0
  • node.js version: v12.18.2
  • OS: Ubuntu 16.04

Possible Solution
Looks like invocationRoute.js changed to return an async function but didn't properly fix the key-value mapping on the return object and might not be handling the await downstream. See v6.7.0...master#diff-c23f5dac27510ddbb5b7b60780e7571dR12.

@VincentClair
Copy link

VincentClair commented Sep 16, 2020

Hello, maybe it's the same issue as #1075.
But the actual answer is not the ideal solution. Here we rollback serverless-offline to v6.6.0

@dustinsgoodman
Copy link
Author

@VincentClair looks like #1075 is definitely related. However, it is closed with no real resolution. Looks like there might a breaking change in the codebase which is probably less than ideal.

@yocmen
Copy link

yocmen commented Sep 16, 2020

I got the same error trying to promisify redis, the first request works, the second one:

offline: Failure: The "original" argument must be of type function. Received undefined

@josimarz
Copy link

I'm having trouble with this issue too. For a while I'm using the version 6.5.0. With the newest version, every request makes start a new application. This causes trouble when using TypeORM, for example.

@maxgr0
Copy link

maxgr0 commented Sep 19, 2020

This issue causes trouble in type-graphql too after upgrading from 6.4.0 to 6.7.0.

@jonathanalberghini
Copy link

I am having the same issue. This is limited to above 6.4.0. We use offline to test our code in the deployment pipeline.
We can only make one call and then it errors out
`'use strict'

const { spawn } = require('child_process')
const axios = require('axios')

const { slsOffline, updateBearerToken, updateAccountBearerToken, updateLoginInfo, loginData } = require('./config')

let slsOfflineProcess

before(async () => {
console.log('[Tests Bootstrap] Start')
// Make sure to clean up any orphan sls processes
spawn('pkill', ['-f', 'sls'])

await startSlsOffline()
console.log('Server ready')
// await Promise.delay(10000) // We must wait for sls offline to actually be ready to listen for requests
console.log('[Tests Bootstrap] Done')
})

async function startSlsOffline () {
const env = Object.create(process.env)
// env.AUTHORIZER = '{"principalId": "SAC0011743569:d701d1d0-5f94-11e9-b8d3-f53452b983ed"}'
const stage = process.env.TEST_STAGE
const path = 'pb/login/'
try {
const login = stage === 'prod' ? await prodLogin.post(path, loginData) : await devLogin.post(path, loginData)
updateBearerToken(login.data.token)
updateAccountBearerToken(login.data.accountToken)
updateLoginInfo(login.data.loginId)
// env.AUTHORIZER = '{"principalId": "' + login.data.loginId + '"}'
// console.log(env.AUTHORIZER)
// console.log(login.data.loginId)
// console.log(getBearerToken())
} catch (e) {
throw new Error(e)
}
slsOfflineProcess = spawn('sls', ['offline', 'start', '--stage', process.env.TEST_STAGE, '--httpPort', slsOffline.port, '--apiKey', slsOffline.key], { env: env })
console.log(Serverless: Offline started with PID : ${slsOfflineProcess.pid} STAGE : ${process.env.TEST_STAGE})
for await (const data of slsOfflineProcess.stdout) {
if (data.includes('offline: [HTTP] server ready:')) {
console.log(data.toString().trim())
return
} else if (data.includes('Serverless Error')) {
console.log(data.toString().trim())
throw new Error(data.toString().trim())
}
}
slsOfflineProcess.stderr.on('data', (errData) => {
console.log(Error starting Serverless Offline:\n${errData})
throw new Error(errData)
})
}

after(() => {
console.log('[Tests Teardown] Start')
stopSlsOffline()
console.log('[Tests Teardown] Done')
})

function stopSlsOffline () {
slsOfflineProcess && slsOfflineProcess.kill()
console.log(slsOfflineProcess.killed)
// The above doesn't actually kill the process on my end, even though it sends the kill signal and reports it
// Kill it with fire!
spawn('pkill', ['-f', 'sls'])
console.log('Serverless Offline stopped')
}
`

@dustinsgoodman
Copy link
Author

@dherault just pointed out that v6.8.0 was released today in the Gitter. I've updated dustinsgoodman/serverless-microservices-graphql-template#13 to use v6.8.0 and this issue has been resolved using the latest. Closing since the issue is now resolved.

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

No branches or pull requests

6 participants