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

[BUG] < Packaging app for deployment✘ [ERROR] Cannot convert undefined or null to object [plugin deno-loader]> #374

Open
MitchDevLissi opened this issue Nov 7, 2024 · 6 comments
Labels
bug Something isn't working bundling known issue related to bundling needs info not enough information to reproduce or continue question Further information is requested

Comments

@MitchDevLissi
Copy link

Hello,
basically, I am developing a trigger, and with slack run, it runs smoothly, but with slack deploy, I have the following error:

⠼ Packaging app for deployment✘ [ERROR] Cannot convert undefined or null to object [plugin deno-loader] Error bundling function file "function" with esbuild error: Uncaught (in promise) Error: Build failed with 1 error: error: Cannot convert undefined or null to object let error = new Error(text); ^ at failureErrorWithLog (https://deno.land/x/[email protected]/mod.js:1626:15) at https://deno.land/x/[email protected]/mod.js:1035:25 at runOnEndCallbacks (https://deno.land/x/[email protected]/mod.js:1461:45) at buildResponseToResult (https://deno.land/x/[email protected]/mod.js:1033:7) at https://deno.land/x/[email protected]/mod.js:1062:16 at responseCallbacks.<computed> (https://deno.land/x/[email protected]/mod.js:679:9) at handleIncomingPacket (https://deno.land/x/[email protected]/mod.js:739:9) at readFromStdout (https://deno.land/x/[email protected]/mod.js:655:7) at https://deno.land/x/[email protected]/mod.js:1924:11 at eventLoopTick (ext:core/01_core.js:175:7) Packaging app for deployment
I'm Using:
slack v2.30.1
deno 2.0.4 (stable, release, aarch64-apple-darwin)
v8 12.9.202.13-rusty
typescript 5.6.2

Actually, I have this error even with empty functions basically, what could it be?

Thanks a lot!

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

@filmaj
Copy link
Contributor

filmaj commented Nov 7, 2024

Can you try downgrading deno to 1.x? E.g. 1.46.3 is the last deno 1.x version. I think you can do that with deno upgrade --version 1.46.3.

For context, here is what's happening:

  1. As part of slack deploy, we "bundle" your app into a single .js file.
  2. This bundling uses esbuild under the hood (as native bundling tools in deno have been deprecated / removed).
  3. esbuild has not been great for us here, there are many situations where it fails 😢 (see e.g slack deploy fails on Windows but is successful on Linux #316 and [QUERY] How to deploy with npm module dependencies? deno-slack-hooks#89). It regularly fails to bundle when using more complex npm dependencies, or on Windows, for example.

@filmaj filmaj added bug Something isn't working question Further information is requested needs info not enough information to reproduce or continue bundling known issue related to bundling labels Nov 7, 2024
@MitchDevLissi
Copy link
Author

MitchDevLissi commented Nov 7, 2024

I updated it, I changed the import_map.json, I followed this guide for the environment variables (https://api.slack.com/automation/environment-variables#access-function)
Now I have this error

error: Uncaught (in promise) TypeError: Requires net access to "esm.sh:443", run again with the --allow-net flag
    at file:emailSending.ts:4:30
    const manifestJSFile = await import(`file://${manifestJSFilePath}`);
                           ^
    at async readImportedManifestFile (https://deno.land/x/[email protected]/manifest.ts:101:28)
    at async createManifest (https://deno.land/x/[email protected]/manifest.ts:19:22)
    at async runLocally (https://deno.land/x/[email protected]/local-run-function.ts:21:20)
    at async https://deno.land/x/[email protected]/local-run-function.ts:55:3
Check /Users/user/.slack/logs/slack-debug-20241107.log for error logs

Here is the specified line
import { authenticate } from '@google-cloud/local-auth';
So with the newer version of Deno, I can deploy, but then it does not work, with the older version of Deno, I can deploy, but then when the function is running, it gives the specified error.
Thanks for the support!

@filmaj
Copy link
Contributor

filmaj commented Nov 7, 2024

Can you share the contents of the slack.json and import_map.json files for your app?

@MitchDevLissi
Copy link
Author

import_map.json
{ "imports": { "deno-slack-sdk/": "https://deno.land/x/[email protected]/", "deno-slack-api/": "https://deno.land/x/[email protected]/", "microsoft-graph-client": "https://esm.sh/@microsoft/[email protected]", "microsoft-graph-types": "https://esm.sh/@microsoft/[email protected]", "std/": "https://deno.land/[email protected]/", "@google-cloud/local-auth": "https://esm.sh/@google-cloud/[email protected]", "googleapis": "https://esm.sh/[email protected]" } }

Slack.json

{ "hooks": { "get-hooks": "deno run --allow-all https://deno.land/x/deno_slack_hooks/mod.ts" } }

@filmaj
Copy link
Contributor

filmaj commented Nov 7, 2024

Thanks.

So with the newer version of Deno, I can deploy, but then it does not work, with the older version of Deno, I can deploy, but then when the function is running, it gives the specified error.

In the sentence above you say "I can deploy" in both cases - I think one of these is supposed to be "cannot", yes?

Try adding esm.sh to your manifest.ts' outgoingDomains array; that should fix the issue when running locally, which I believe is where you are seeing the issue right now.

In general, if/until the deployed environment supports deno 2 (it currently runs on 1.46.2 which you can always check by looking at the deno-runtime property in https://api.slack.com/slackcli/metadata.json), we recommend using the same version of deno locally as Slack runs in the cloud when running your app, to ensure identical behaviour.

@MitchDevLissi
Copy link
Author

What u mean 'adding adding esm.sh to your manifest.ts' outgoingDomains array'?
Exactly, I can deploy but not running locally with 1.46.3, and I can t deploy but running locally with the newer version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bundling known issue related to bundling needs info not enough information to reproduce or continue question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants