99x / 99x/serverless-dynamodb-client

process.env.IS_OFFLINE is always undefined

Open
#1 0 comments 13 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
74
Forks
16
PR merge metrics
No merged PRs in 30d

Description

### Scenario
Suppose you have configured plugins `serverless-dynamodb-local`, `serverless-offline` and `serverless-dynamodb-client`. Then, you execute commands
> `$ sls offline &` [1]
> `$ sls invoke local -f function --path input.json` [2]

### Result
The *AWS* dynamodb instance will be used, not the local one.

### Explanation
The reason is that:
* command [1] sets environment variable `IS_OFFLINE` not to the parent shell but to the `sls offline` process
* when command [2] is executed, it inherits the environment of the shell, which has no `IS_OFFLINE` defined. So, when `require('serverless-dynamodb-client')` is called, `isOffline()` always returns false.

### Workaround
Execute
> `$ export IS_OFFLINE=true`

before command [2]

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the `require('serverless-dynamodb-client')` entry point and the `isOffline()` check described in the issue, using the `sls offline` and `sls invoke local` commands to reproduce the environment behavior. Done means invoking the function locally selects the local DynamoDB instance without requiring `export IS_OFFLINE=true`.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.