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

Docker Bug: Should soft fail and continue on fallocate not available #3052

Closed
heri16 opened this issue May 28, 2018 · 2 comments
Closed

Docker Bug: Should soft fail and continue on fallocate not available #3052

heri16 opened this issue May 28, 2018 · 2 comments

Comments

@heri16
Copy link

heri16 commented May 28, 2018

Goals

Trying to run realm-js on nodejs 8.10 AWS Lambda.

Expected Results

Should be able to open a realm path on /tmp

Actual Results

{
    "errorMessage": "posix_fallocate() failed: Operation not permitted",
    "errorType": "Error",
    "stackTrace": [
        "Function.open (/var/task/node_modules/realm/lib/extensions.js:72:47)",
        "exports.handler (/var/task/api/realm.js:45:25)"
    ]
}

Steps to Reproduce

  1. Create a serverless framework project.
  2. npm install realm.
  3. Deploy the function below: sls deploy -f realm
  4. Try invoking the function below: sls invoke -f realm --data "{'test': 'ok'}"

Code Sample

'use strict'

// See: https://realm.io/docs/javascript/latest/#getting-started

const process = require('process')

const debug = require('debug')('realm')
const Realm = require('realm')

const CarSchema = {
  name: 'Car',
  properties: {
    make: 'string',
    model: 'string',
    miles: { type: 'int', default: 0 },
  },
}

// Define new ES6 class
class Person {
  get fullName() {
    return `${this.firstName} ${this.lastName}`
  }

  static get schema() {
    return {
      name: 'Person',
      properties: {
        name: 'string',
        birthday: 'date',
        cars: 'Car[]',
        picture: 'data?', // optional property
      },
    }
  }
}

exports.handler = async (event, context) => {
  console.log('Received event', JSON.stringify(event, 3)) // eslint-disable-line no-console
  console.log('Received context', JSON.stringify(context, 3)) // eslint-disable-line no-console

  let realm
  try {
    process.chdir('/tmp')
    realm = await Realm.open({
      path: '/tmp/cars.realm',
      inMemory: true,
      schema: [CarSchema, Person],
    })
  } catch (err) {
    console.error(err) // eslint-disable-line no-console
    throw err
  }

  // Create Realm objects and write to local storage
  realm.write(() => {
    const myCar = realm.create('Car', {
      make: 'Honda',
      model: 'Civic',
      miles: 1000,
    })
    myCar.miles += 20 // Update a property value
  })

  // Query Realm for all cars with a high mileage
  const cars = realm.objects('Car').filtered('miles > 1000')

  // Will return a Results object with our 1 car
  debug('cars.length:', cars.length) // => 1

  // Add another car
  realm.write(() => {
    realm.create('Car', {
      make: 'Ford',
      model: 'Focus',
      miles: 2000,
    })
  })

  // Query results are updated in realtime
  debug('cars.length:', cars.length) // => 2
  console.log('cars.length:', cars.length) // eslint-disable-line no-console

  return {
    statusCode: 200,
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(cars),
  }
}

Version of Realm and Tooling

  • Realm JS SDK Version: ? Latest
  • Node or React Native: ? Nodejs v8.10
  • Client OS & Version: AWS Lambda Runtime
  • Which debugger for React Native: None
@heri16
Copy link
Author

heri16 commented May 28, 2018

@heri16 heri16 changed the title Bug: Should soft fail and continue on fallocate not available Docker Bug: Should soft fail and continue on fallocate not available Jun 7, 2018
@ironage
Copy link
Contributor

ironage commented Feb 5, 2019

This seems like a duplicate of #3193 and should be fixed by #3195.

@ironage ironage closed this as completed Feb 5, 2019
@ironage ironage added T-Duplicate and removed T-Bug labels Feb 5, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants