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
After update to 4.5.6 Azure NodeJS Function Fails - isPlainObject is not a functionat Object.keys.forEach.key #195
Comments
Do you have a lock file? Could you provide the output of I'm not able to reproduce the problem with the information you shared. If you could create a minimal test that would be great. runkit.com/ is great for that, see https://runkit.com/gr2m/octokit-rest-js-1808 for an example |
@gr2m this works fine locally for me, it is only when this is pushed into Azure itself that it causes this problem, which is obviously tricky to replicate. With this seeming to be specific to Azure as I can not reproduce this locally, I am not sure a RunKit will help us, but will create one if you want me to. If there any other details or specifics you wish for me to investigate with Azure to help diagnose then please let me know :) For reference my relatively simple Azure Function code using Octokit/GraphQL is here Poking around in Azure Portal it mentions it is running 10.19.0 of Node Result of npm ls (Local Machine)Result of npm ls (Azure)package.lock.json{
"name": "isgithubsponsor",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@azure/functions": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@azure/functions/-/functions-1.2.2.tgz",
"integrity": "sha512-p/dDHq1sG/iAib+eDY4NxskWHoHW1WFzD85s0SfWxc2wVjJbxB0xz/zBF4s7ymjVgTu+0ceipeBk+tmpnt98oA==",
"dev": true
},
"@octokit/endpoint": {
"version": "6.0.6",
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.6.tgz",
"integrity": "sha512-7Cc8olaCoL/mtquB7j/HTbPM+sY6Ebr4k2X2y4JoXpVKQ7r5xB4iGQE0IoO58wIPsUk4AzoT65AMEpymSbWTgQ==",
"requires": {
"@octokit/types": "^5.0.0",
"is-plain-object": "^5.0.0",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/graphql": {
"version": "4.5.6",
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.5.6.tgz",
"integrity": "sha512-Rry+unqKTa3svswT2ZAuqenpLrzJd+JTv89LTeVa5UM/5OX8o4KTkPL7/1ABq4f/ZkELb0XEK/2IEoYwykcLXg==",
"requires": {
"@octokit/request": "^5.3.0",
"@octokit/types": "^5.0.0",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/request": {
"version": "5.4.9",
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.9.tgz",
"integrity": "sha512-CzwVvRyimIM1h2n9pLVYfTDmX9m+KHSgCpqPsY8F1NdEK8IaWqXhSBXsdjOBFZSpEcxNEeg4p0UO9cQ8EnOCLA==",
"requires": {
"@octokit/endpoint": "^6.0.1",
"@octokit/request-error": "^2.0.0",
"@octokit/types": "^5.0.0",
"deprecation": "^2.0.0",
"is-plain-object": "^5.0.0",
"node-fetch": "^2.6.1",
"once": "^1.4.0",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/request-error": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.0.2.tgz",
"integrity": "sha512-2BrmnvVSV1MXQvEkrb9zwzP0wXFNbPJij922kYBTLIlIafukrGOb+ABBT2+c6wZiuyWDH1K1zmjGQ0toN/wMWw==",
"requires": {
"@octokit/types": "^5.0.1",
"deprecation": "^2.0.0",
"once": "^1.4.0"
}
},
"@octokit/types": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-5.5.0.tgz",
"integrity": "sha512-UZ1pErDue6bZNjYOotCNveTXArOMZQFG6hKJfOnGnulVCMcVVi7YIIuuR4WfBhjo7zgpmzn/BkPDnUXtNx+PcQ==",
"requires": {
"@types/node": ">= 8"
}
},
"@types/node": {
"version": "14.10.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.10.1.tgz",
"integrity": "sha512-aYNbO+FZ/3KGeQCEkNhHFRIzBOUgc7QvcVNKXbfnhDkSfwUv91JsQQa10rDgKSTSLkXZ1UIyPe4FJJNVgw1xWQ=="
},
"deprecation": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
"integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ=="
},
"is-plain-object": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q=="
},
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
"wrappy": "1"
}
},
"typescript": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz",
"integrity": "sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==",
"dev": true
},
"universal-user-agent": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
}
}
} |
It all looks correct to me ... Could you create a much more reduced function and see if it causes the same problem, something like this? import { Context, HttpRequest } from "@azure/functions"
import { graphql } from "@octokit/graphql";
// Azure Function HTTP Trigger entry point
export default async function (context: Context, req: HttpRequest): Promise<void> {
const userToken = (req.query.token || (req.body && req.body.token));
const graphqlWithAuth = graphql.defaults({
headers: {
authorization: `token ${userToken}`,
},
});
const { data } = await graphqlWithAuth(`{
viewer {
login
}
}`)
console.log(data)
context.res = {
status: 200,
body: data
}
context.done()
} Can you tell what windows operating system the function is running on? We could try to reproduce it with GitHub Actions running on Windows |
Azure Windows OSAzure = 10.0.14393.0 Simple exampleI have deployed the simple example too and also get the error Git Commit in Repo that Deployed to Azure Functions Works locally in VSCodeLive Logs from Azure
|
I haven't had time yet, but come across this repo from MS/Azure Functions that may give some insight how this runs on Azure with the slightly vague error we have Maybe someone from that team/repo could give some insights? @mhoeger @pragnagopa @yojagad are any of you or anyone you know on your team who could give advice into debugging this problem and understanding why this would work locally but as soon as deployed to an Azure Function it no longer works. |
I've tried to reproduce the problem using the available windows version on GItHub actions, but to no avail:
My test case is here: Lines 1 to 25 in a6d0bff
run from this workflow file: graphql.js/.github/workflows/test.yml Lines 1 to 18 in a6d0bff
|
Thanks for the update. Interesting it’s all fine on a GitHub Action. I suspect there is something specific happening when run as an Azure Function and is environment specific. If you want me to try anything else let me know please. |
having the same issue here when deploying this code to AWS Lambda, although i think its probably an artifact of the bundling process, not the actual environment itself. while i haven't been able to dive deeper into exactly why if you're using
at least got my code working in Lambda with |
Do you use any kind of bundling with webpack or similar? |
@jnwng I tried to reproduce the problem on AWS using the Could you share more details please? I really appreciate both your help to identify the cause of the problem |
Currently waiting to hear back from MS/Azure team in the above ticket ⬆️ |
I may close this issue as it currently can not be reproduced in a new Azure Function If I ever encounter this problem again or if anyone else does I suggest we re-open this to try & investigate further |
Thank you Warren for staying on top of it 👍🏼 |
<!--- write down the issue related to this PR--> ## Description <!--- Describe your changes in detail --> This PR attempts to resolve the `is-plain-object` dependency issue by following this comment: octokit/graphql.js#195 (comment) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] My code follows the code style of this project. - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly.
Problem
After upgrading to the latest version 4.5.6 a NodeJS serverless Azure Function now complains about
isPlainObject is not a function at Object.keys.forEach.key
If I revert the package.json dependency back to 4.5.4 then it continues to work as it once did.
Error
The text was updated successfully, but these errors were encountered: