Giter VIP home page Giter VIP logo

fxa-basket-proxy's Introduction

fxa-basket-proxy's People

Contributors

g-k avatar jbuck avatar jrgm avatar rfk avatar seanmonstar avatar vbudhram avatar vladikoff avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fxa-basket-proxy's Issues

Wiki changes

FYI: The following changes were made to this repository's wiki:

  • defacing spam has been removed

  • the wiki has been disabled, as it was not used

These were made as the result of a recent automated defacement of publically writeable wikis.

Replace grunt-nsp-shrinkwrap with grunt-nsp

I think we can use something like this:

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

module.exports = function (grunt) {
  'use strict';

  grunt.config('nsp', {
    output: 'summary',
    shrinkwrap: grunt.file.readJSON('npm-shrinkwrap.json'),
  });
};

Include a source_url in all calls to /subscribe

The source_url is used by basket to track their traffic. Currently we send this when automagically subscribing users to a newsletter campaign in response to a signup event, but we don't send it for users who click the "get the latest news" checkbox on the signup form.

For a start, we can send the generic "https://accounts.firefox.com". In a future iteration we could try harder to include various utm_* parameters etc.

stacks for uncaughtExceptions from basket calls

Followup to #16. Two uncaught today, with a restart. Basket was throwing back a bunch of failures, and I suppose in a race we had stacks like the below:

{"Timestamp":1456085723339000000,"Logger":"fxa-basket-proxy","Type":"routes.lookup-user.error","Severity":2,"Pid":15646,"EnvVersion":"2.0","Fields":{"er\
ror":"Error: ESOCKETTIMEDOUT","stack":"
    at ClientRequest.<anonymous> (/data/fxa-basket-proxy/node_modules/request/request.js:779:19)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.emit (events.js:92:17)
    at Socket.emitTimeout (http.js:1800:10)
    at Socket.g (events.js:180:16)
    at Socket.emit (events.js:117:20)
    at Socket._onTimeout (net.js:327:8)
    at _makeTimerTimeout (timers.js:438:11)
    at Timer.unrefTimeout [as ontimeout] (timers.js:502:5)"}}
{"Timestamp":1456085723341000000,"Logger":"fxa-basket-proxy","Type":"uncaughtException","Severity":0,"Pid":15646,"EnvVersion":"2.0","Fields":{"error":"E\
rror: Can't set headers after they are sent.","stack":"
    at ServerResponse.OutgoingMessage.setHeader (http.js:690:11)
    at ServerResponse.header (/data/fxa-basket-proxy/node_modules/express/lib/response.js:718:10)
    at ServerResponse.send (/data/fxa-basket-proxy/node_modules/express/lib/response.js:163:12)
    at ServerResponse.json (/data/fxa-basket-proxy/node_modules/express/lib/response.js:249:15)
    at Request.<anonymous> (/data/fxa-basket-proxy/lib/routes/lookup.js:22:23)
    at Request.emit (events.js:117:20)
    at ClientRequest.<anonymous> (/data/fxa-basket-proxy/node_modules/request/request.js:782:16)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.emit (events.js:92:17)
    at Socket.emitTimeout (http.js:1800:10)
    at Socket.g (events.js:180:16)
    at Socket.emit (events.js:117:20)
    at Socket._onTimeout (net.js:327:8)
    at _makeTimerTimeout (timers.js:438:11)
    at Timer.unrefTimeout [as ontimeout] (timers.js:502:5)"}}

`LOG_LEVEL=critical` hides important test failures

In #24, I've updated to mozlog 2.0.4. However, I happened to notice the following in the previous production release 0.59.0 (f072430)

npm test is set to be LOG_LEVEL=critical grunt test --node-env=test, and passes in 0.59.0.

However, if I remove LOG_LEVEL=critical (or change it to LOG_LEVEL=error or lower), there are now 4 failing tests reporting the problem reported in mozilla/mozlog#11 and fixed in [email protected].

The tests cause errors to be logged at ERROR level (2):

{"Timestamp":1463884615312000000,"Logger":"fxa-basket-proxy","Type":"verify.auth.error",
 "Severity":2,"Pid":30825,"EnvVersion":"2.0","Fields":{"error":"Error: ruh-roh!","stack":"
    at RequestOverrider.end (/an/example/fxa-basket-proxy/node_modules/nock/lib/request_overrider.js:284:17)
    at OverriddenClientRequest.RequestOverrider.req.end (/an/example/fxa-basket-proxy/node_modules/nock/lib/request_overrider.js:160:7)
    at Request.end (/an/example/fxa-basket-proxy/node_modules/request/request.js:1383:12)
    at end (/an/example/fxa-basket-proxy/node_modules/request/request.js:563:14)
    at Object._onImmediate (/an/example/fxa-basket-proxy/node_modules/request/request.js:589:7)
    at processImmediate [as _immediateCallback] (timers.js:363:15)"}}

And with LOG_LEVEL=error, the logging code is exercised resulting in test failures:

  1) the route /lookup-user returns an error if the basket server request errors out:
     Uncaught TypeError: Cannot set property 'stack' of undefined
      at HekaFormatter.hekaFormat [as format] (node_modules/mozlog/lib/format.js:94:22)
      at StreamHandler.format (node_modules/mozlog/node_modules/intel/lib/handlers/handler.js:52:28)
      at StreamHandler.streamEmit [as _emit] (node_modules/mozlog/node_modules/intel/lib/handlers/stream.js:21:27)
      at StreamHandler.emit (node_modules/mozlog/node_modules/intel/lib/handlers/handler.js:13:15)
      at Logger.handle (node_modules/mozlog/node_modules/intel/lib/logger.js:218:29)
      at Logger.handle (node_modules/mozlog/node_modules/intel/lib/logger.js:226:15)
      at Logger._log (node_modules/mozlog/node_modules/intel/lib/logger.js:249:20)
      at Logger.error (node_modules/mozlog/node_modules/intel/lib/logger.js:81:19)
      at Request.<anonymous> (lib/basket/index.js:132:8)
      at Request.onRequestError (node_modules/request/request.js:821:8)
      at node_modules/nock/lib/request_overrider.js:207:11

LOG_LEVEL=error does mean spew to console when running tests, but does mean a more valid reflection of what can happen in production.

Add a date-based killswitch to "login" event handling

We want to move the handling of "login" SQS events from this repo over to basket, per mozmeao/basket#37. Unfortunately the handling of login events is not idempotent so we need a way to do a clean cutover between the two systems.

Our proposal, as described in mozmeao/basket#37 (comment), is to use the "ts" field in the event message to manage this. We will ship code on both the basket and basket-proxy side so that:

  • basket silently discards events with ts < X, but processes events with ts >= X
  • basket-proxy handles events with ts < X, but silently discards events with ts >= X

We can fill in the value of X once the code is ready and QA'd on both sides. We migth also consider keeping the ts >= X messages in the queue on the basket-proxy side, as a backup until we're sure the new basket code is working correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.