Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/platforms/javascript/common/troubleshooting/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -691,4 +691,28 @@ shamefully-hoist=true
</Expandable>
</PlatformSection>

<PlatformSection supported={["javascript.deno"]}>

<Expandable permalink title="The app stops at startup with `SyntaxError: Unexpected token ':'`">

Your app imports a dependency that calls `require()` on a JSON file, and the `@sentry/deno/import` hook is active. Deno compiles the JSON as JavaScript instead, and the process stops before your code runs:

```
error: Uncaught SyntaxError: Unexpected token ':'
```

This is a Deno bug ([denoland/deno#36240](https://github.com/denoland/deno/issues/36240)): while any module hook is registered, Deno loads `.json` files with the wrong format. Express, Fastify, Hapi, Koa and mysql2 all read a JSON file this way.

Remove the `@sentry/deno/import` line from your entry file to start your app again:

```javascript {filename: main.ts}
import * as Sentry from "npm:@sentry/deno";
```

Errors, `Deno.serve` and `node:http` spans, logs and metrics all keep working without the hook. You lose the integrations that depend on it, such as `mysql` 2.x and `pg`. Drivers that publish their own diagnostics channels, among them `mysql2` 3.20.0 and later and `ioredis` 5.11.0 and later, are instrumented either way.

</Expandable>

</PlatformSection>

If you need additional help, you can [ask on GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose). Customers on a paid plan may also contact support.
61 changes: 42 additions & 19 deletions docs/platforms/javascript/guides/deno/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ Choose the features you want to configure, and this guide will show you how:
<SplitSection>
<SplitSectionText>

Import the Sentry Deno SDK directly from the npm registry, before importing any other modules:
Import the Sentry Deno SDK directly from the npm registry, before importing any other modules. The first line registers the hook that instruments your database drivers, message queues, AI libraries and web frameworks. It only works as the first import of your entry file:

</SplitSectionText>
<SplitSectionCode>

```javascript {filename: main.ts}
import "___SDK_PACKAGE___/import";
import * as Sentry from "___SDK_PACKAGE___";
// your other imports
```
Expand All @@ -49,6 +50,28 @@ import * as Sentry from "___SDK_PACKAGE___";
</SplitSection>
</SplitLayout>

<SplitLayout>
<SplitSection>
<SplitSectionText>

The hook reads your dependencies from a local `node_modules` directory, not from Deno's global npm cache. Set `nodeModulesDir` in your `deno.json`:

</SplitSectionText>
<SplitSectionCode>

```json {filename: deno.json}
{
"imports": {
"@sentry/deno": "npm:@sentry/deno"
},
"nodeModulesDir": "auto"
}
```

</SplitSectionCode>
</SplitSection>
</SplitLayout>

## Configure

### Initialize the Sentry SDK
Expand All @@ -63,6 +86,7 @@ Initialize Sentry as early as possible in your app:
<SplitSectionCode>

```javascript {filename: main.ts}
import "___SDK_PACKAGE___/import";
import * as Sentry from "___SDK_PACKAGE___";
// your other imports

Expand All @@ -85,43 +109,42 @@ Sentry.init({
</SplitSection>
</SplitLayout>

### Enable Network Access
### Grant Permissions

<SplitLayout>
<SplitSection>
<SplitSectionText>

To make sure the SDK can send events, enable network access for your Sentry ingestion domain:
Deno blocks access to the network, the file system and system information until you grant it. Start your app with all four permissions so that the SDK can send complete events. Add the other hosts your app talks to, separated by commas:

</SplitSectionText>
<SplitSectionCode>

```bash
deno run --allow-net=___ORG_INGEST_DOMAIN___ index.ts
deno run \
--allow-net=___ORG_INGEST_DOMAIN___ \
--allow-env \
--allow-read=. \
--allow-sys=hostname,osRelease \
main.ts
```

</SplitSectionCode>
</SplitSection>
</SplitLayout>

### Allow Access to Source Files
<Expandable permalink={false} title="What each permission gives you">

<SplitLayout>
<SplitSection>
<SplitSectionText>

Grant read access to your source files so that the SDK can include your source code in stack traces:

</SplitSectionText>
<SplitSectionCode>
| Flag | What it gives you |
| -------------------------------- | -------------------------------------------------------------------------------------------- |
| `--allow-net=<host>` | Delivery of events to Sentry. If a host is missing, Deno names it in the error. |
| `--allow-env` | The import hook. Without it, your app stops at start with `NotCapable: Requires env access`. |
| `--allow-read=.` | Source code in stack traces, and `app:///` paths instead of absolute paths. |
| `--allow-sys=hostname,osRelease` | The server name and the operating system version on events. |

```bash
deno run --allow-read=./src index.ts
```
If you omit `--allow-read` or `--allow-sys`, the SDK sends events without that data and prints no warning.

</SplitSectionCode>
</SplitSection>
</SplitLayout>
</Expandable>

### Add Readable Stack Traces With Source Maps (Optional)

Expand Down
28 changes: 18 additions & 10 deletions platform-includes/crons/setup/javascript.deno.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
## Automatic Check-Ins (Recommended)
## Job Monitoring

<Include name="javascript-crons-job-monitoring.mdx" />

## Check-Ins

<Include name="javascript-crons-checkins.mdx" />

## Automatic Check-Ins With `Deno.cron`

<Alert level="warning">

The `DenoCron` integration does not work on Deno 2.9.0 and later. On these versions `Deno.cron` is a read-only property, so `Sentry.init` stops with `TypeError: Cannot set property cron of #<Object> which has only a getter` and your app does not start. Use `Sentry.withMonitor` or `Sentry.captureCheckIn` instead.

_requires SDK version 7.88.0 or higher_
</Alert>

_requires SDK version 7.88.0 or higher, and Deno 2.8.3 or earlier_

Use the `DenoCron` integration to monitor your [`Deno.cron`](https://deno.com/blog/cron) calls and get notified when a schedule job is missed (or doesn't start when expected), if it fails due to a problem in the runtime (such as an error), or if it fails by exceeding its maximum runtime.

The integration is not part of the default set, so you must add it to `integrations` yourself:

```TypeScript
import * as Sentry from "___SDK_PACKAGE___";

Expand All @@ -13,14 +29,6 @@ Sentry.init({
});
```

## Job Monitoring

<Include name="javascript-crons-job-monitoring.mdx" />

## Check-Ins

<Include name="javascript-crons-checkins.mdx" />

## Upserting Cron Monitors

<Include name="javascript-crons-upsert.mdx" />
Loading