Sync Gateway _config REST endpoint not working as expected

I am trying to do a PUT to the _config endpoint using the admin port of the Sync Gateway (v1.3.1)/

Here is the PUT body:

{
  "server": "http://clusternode:8091/",
  "pool": "default",
  "bucket": "default",
  "name": "default",
  "sync": "function(doc, oldDoc){throw({forbidden:'Hello World'}); }",
  "users": {
    "GUEST": {
      "name": "",
      "all_channels": null
    }
  }
}

The server returns a response of 201 Created. When I submit a GET to the _config endpoint, the updated configuration is returned as expected. However, this configuration does not seem to be used at all by the Sync Gateway.

If I then try to save a document to the Sync Gateway, I expect to receive a “forbidden” response. Instead, the previous (original) Sync Function is used and the exception is not thrown at all. It seems to always be using the settings from the “sync_gateway.json” file from /home/sync_gateway.

I have tried restarting the Sync Gateway service after the issuing the PUT, but this has had no affect.

Any ideas?

Update:

That seems to be the case, here are the steps I took to test the scenario.

The updated config is applied after taking the database offline and online.

  1. Start sync gateway without a config file.

  2. Install CORS proxy to allow sending request from the browser (needed in step below).

    npm install -g corsproxy
    corsproxy
    
    > 170202/173725.478, [log,info], data: CORS Proxy running at: http://localhost:1337
    
  3. Open http://codepen.io/Jamiltz/pen/QdrjOY?editors=1011 and run the following.

It updates the sync function and creates a user (name: foo/password: bar). Following the config update, another doc isn’t persisted as expected when it should be rejected. And the user doesn’t does exist after the update.

@adamf, can you confirm what the expected behaviour is here?

Filed a documentation ticket https://github.com/couchbaselabs/couchbase-mobile-portal/issues/539.

Thanks, taking it offline and online again did the trick.